search
Homephp教程php手册给ECShop添加最新评论,ECShop添加最新评论

给ECShop添加最新评论,ECShop添加最新评论

我直接写上操作步骤吧,看下思路,相信大家也会了

第一步:

在includes/lib_goods.php里面构建自定义函数

复制代码 代码如下:


/**
 * 获取最近评论
 *
 * @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;
}

 第二步:

在根目录的goods.php的$smarty->assign('goods_rank',          get_goods_rank($goods_id));                       // 商品的销售排名

下面添加以下代码

复制代码 代码如下:


$smarty->assign('comments_latest',     get_latest_comment(10));                 //获取最新品论

 第三步:

在library目录下创建comments_latest.lbi文件

第四步:

在模板文件goods.dwt中使用以下代码即可在商品详情页面中调用“最新评论”

复制代码 代码如下:



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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.