This article describes how to add the latest comments to ECShop and how to share the Code. For more information, see
This article describes how to add the latest comments to ECShop and how to share the Code. For more information, see
Let me directly write down the operation steps. Let's take a look at the ideas. I believe everyone will do the same.
Step 1:
Build a UDF in includes/lib_goods.php
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:
In the root directory of goods. php, $ smarty-> assign ('goods _ rank ', get_goods_rank ($ goods_id); // The sales ranking of the Product
Add the following code
The Code is as follows:
$ Smarty-> assign ('comments _ latest ', get_latest_comment (10); // get the latest product Theory
Step 3:
Create the comments_latest.lbi file in the library directory.
Step 4:
Use the following code in the template file goods. dwt to call the "latest comment" on the product details page"
The Code is as follows: