This article mainly introduces how to add the latest comments to ECShop and how to share the code. if you want to share the comments, you can refer to the Operation steps below and read the ideas.
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: