Home >Backend Development >PHP Tutorial >Add the latest comments to ECShop, add the latest comments to ECShop_PHP Tutorial

Add the latest comments to ECShop, add the latest comments to ECShop_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:10:04813browse

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

truehttp: //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...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn