Add the latest comment to Ecshop _php instance

Source: Internet
Author: User

I write the procedure directly, look at the idea, I believe that everyone will be

First step:

Build a custom function inside includes/lib_goods.php

Copy Code code as follows:

/**
* Get Recent comments
*
* @return Array
*/
function get_latest_comment ($limit _num)
{
$sql = "Select C.content,c.add_time,g.goods_id,g.goods_name from". $GLOBALS [' ECS ']->table (' comment '). " As C
Left JOIN ". $GLOBALS [' ECS ']->table (' goods ')." As G on c.id_value=g.goods_id
WHERE C.status=1
LIMIT ". $limit _num;
$res = $GLOBALS [' db ']->getall ($sql);
return $res;
}

Step Two:

In the root directory of the goods.php $smarty->assign (' Goods_rank ', Get_goods_rank ($goods _id)); Sales ranking of goods

Add the following code below

Copy Code code as follows:

$smarty->assign (' Comments_latest ', Get_latest_comment (10)); Get the latest article on

Step Three:

Create a Comments_latest.lbi file in the library directory

Fourth Step:

Use the following code in the template file goods.dwt to invoke "latest comment" in the Commodity Details page

Copy Code code as follows:

<!--#BeginLibraryItem "/library/comments_latest.lbi"--><!--#EndLibraryItem-->

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.