If the product list page of ECSHOP displays the corresponding number of comments, it is better. We can also add browsing times so that the product list looks richer, today, we will explain how to call the comments quantity in the ECSHOP product list. You need to modify the system file. Back up the related files before modification.
Modify a category file
Modify the category. php file and locate the category_get_goods () function.
| The code is as follows: |
Copy code |
$ SQL = 'SELECT g. goods_id, g. goods_name, g. goods_name_style, g. market_price, g. is_new, g. is_best, g. is_hot, g. shop_price AS org_price ,'. "IFNULL (mp. user_price, g. shop_price * '$ _ SESSION [discount]') AS shop_price, g. promote_price, g. goods_type ,". 'G. promote_start_date, g. promote_end_date, g. goods_brief, g. goods_thumb, g. goods_img '. 'From'. $ GLOBALS ['ecs']-> table ('Goods '). 'As G '. 'Left join'. $ GLOBALS ['ecs']-> table ('Member _ price'). 'As MP '. "ON mp. goods_id = g. goods_id AND mp. user_rank = '$ _ SESSION [user_rank]'". "WHERE $ where $ ext order by $ sort $ order "; Change $ SQL = 'SELECT g. goods_id, g. goods_name, g. goods_name_style, g. market_price, g. is_new, g. is_best, g. is_hot, g. shop_price AS org_price ,'. "IFNULL (mp. user_price, g. shop_price * '$ _ SESSION [discount]') AS shop_price, g. promote_price, g. goods_type ,". "IFNULL (AVG (r. comment_rank), 0) AS comment_rank, IF (r. comment_rank, count (*), 0) AS comment_count ,". 'G. promote_start_date, g. promote_end_date, g. goods_brief, g. goods_thumb, g. goods_img '. 'From'. $ GLOBALS ['ecs']-> table ('Goods '). 'As G '. 'Left join'. $ GLOBALS ['ecs']-> table ('Member _ price'). 'As MP '. "ON mp. goods_id = g. goods_id AND mp. user_rank = '$ _ SESSION [user_rank]'". 'Left join'. $ GLOBALS ['ecs']-> table ('Comment'). 'As R '. 'On r. id_value = g. goods_id AND comment_type = 0 AND r. parent_id = 0 AND r. status = 1 '. "WHERE $ where $ ext group by g. goods_id order by $ sort $ order "; Then continue to find $ Arr [$ row ['goods _ id'] ['URL'] = build_uri ('Goods ', array ('gid' => $ row ['goods _ id']), $ row ['goods _ name']); Add several lines of code below it $ Row ['Comment _ rank '] = ceil ($ row ['Comment _ rank']) = 0? 5: ceil ($ row ['Comment _ rank ']); $ Arr [$ row ['goods _ id'] ['Comment _ rank '] = $ row ['Comment _ rank']; $ Arr [$ row ['goods _ id'] ['Comment _ count'] = $ row ['Comment _ count'];
|
Modify Template File
| The code is as follows: |
Copy code |
Modify themes/default/library/goods_list.lbi file to find <A href = "javascript: collect ({$ goods. goods_id});" class = "f6" >{$ lang. btn_collect} </a> Add <br> Comments: {$ goods. comment_count} <br>
|
PS: We all know that the ECSHOP system has a caching mechanism. If a product has a new comment, the number of comments on the list page will not be updated immediately. It will not be updated until the next time the cache is updated.
If you want the list page to instantly reflect changes in the number of comments. You only need to make the following changes.
Put the category. php file
| The code is as follows: |
Copy code |
$ Smarty-> caching = true; Change $ Smarty-> caching = false; |