关于让ecshop商品列表页商品显示一条评论

2016-09-11 20:39 来源:www.chinab4c.com 作者:ecshop专家

 鼠标滑过商品,下方显示最新评论;


无评论时不显示内容;

打开根目录 category.php

大约 447-455行之间

 

/* 获得商品列表 */

    $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, ' .

                "NULLp.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";

    $res = $GLOBALS['db']->sel ectLimit($sql, $size, ($page - 1) * $size);

替换为

    /* 获得商品列表 */

    $sql = 'SELECT g.goods_id,c.id_value,c.user_name,c.content, 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('comment') . ' AS c ON c.id_value = g.goods_id ' .

            '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";

    $res = $GLOBALS['db']->sel ectLimit($sql, $size, ($page - 1) * $size);

然后搜索如下代码:$arr[$row['goods_id']]['name']             = $row['goods_name'];

在其下方添加:

                $arr[$row['goods_id']]['uname']             = $row['user_name'];

                $arr[$row['goods_id']]['ucon']             = $row['content'];

然后打开:根目录/thmes/你的模板/library/goods_list.lib

如果你用的默认模板请搜索:

<a href="javascript:;" id="compareLink" onClick="Compare.add({$goods.goods_id},'{$goods.goods_name|escape:"html"}','{$goods.type}')" class="f6">{$lang.compare}</a>

在其下方添加如下代码:

 <!--{if $goods.uname neq ''}--><p class="rl cl"><em>{$goods.uname}:</em>{$goods.ucon|truncate:26:""}</p><!--{/if}-->

如果不是默认模板请自行查看单个商品循环列表中布局位置.

此时就完成了列表页商品下方的最新评论,只调用1条最新评论.