Add the latest comments to ECShop, add the latest comments to ECShop
I’ll just write down the steps and take a look at the idea, I believe everyone will understand it too
Step one:
Build custom functions in includes/lib_goods.php
Copy code The code is 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 2:
$smarty->assign('goods_rank', get_goods_rank($goods_id));
Add the following code below
Copy code The code is as follows:
$smarty->assign('comments_latest', get_latest_comment(10)); //Get the latest reviews
Step 3:
Create comments_latest.lbi file in the library directory
Step 4:
Use the following code in the template file goods.dwt to call "Latest Comments" on the product details page
Copy code The code is as follows:
http://www.bkjia.com/PHPjc/939408.html
www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/939408.htmlTechArticleAdd the latest comments to ECShop. Add the latest comments to ECShop. I will write the operation steps directly. Take a look at the ideas. I believe you all. Understand the first step: Build customization in includes/lib_goods.php...