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-->