您现在的位置是:首页 > cms教程 > Ecshop商城教程Ecshop商城教程

ecshop首页调用显示最新商品评论

甘风力2023-12-15Ecshop商城教程已有人查阅

导读ECSHOP首页显示很新评论,首页调用商品评论新建立一个 index_comments.lbi 库文件然后在index.dwt 要显示的位置调用:

ECSHOP首页显示很新评论,首页调用商品评论新建立一个 index_comments.lbi 库文件然后在index.dwt 要显示的位置调用:
<!-- #BeginLibraryItem "/libry/index_comments.lbi" --><!-- #EndLibraryItem -->
index_comments.lbi 内容为:
<?php
if(!function_exists("get_comments")){
function get_comments($num)
{
$sql = 'SELECT a.*,b.goods_id,b.goods_thumb,b.goods_name FROM '. $GLOBALS['ecs']->table('comment') .
' AS a,'. $GLOBALS['ecs']->table('goods') .'AS b WHERE a.status = 1 AND a.parent_id = 0 and LENGTH(a.content)>0  and a.comment_type=0 and a.id_value=b.goods_id  '.
' ORDER BY a.add_time DESC';
if ($num > 0)
{
$sql .= ' LIMIT ' . $num;
}
//echo $sql;
$res = $GLOBALS['db']->getAll($sql);
$comments = array();
foreach ($res AS $idx => $row)
{
$comments[$idx]['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']);
$comments[$idx]['content'] = $row['content'];
$comments[$idx]['id_value'] = $row['id_value'];
$comments[$idx]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$comments[$idx]['goods_name'] = $row['goods_name'];
}
return $comments;
}
}
?>
<script type="text/javascript">
function player(id){
var id=document.getElementById(id)
id.style.display="block";
}
function clocer(id){
var id=document.getElementById(id)
id.style.display="none";
}
</script>
<!--数据调用-很新评论开始 -->
​​​​​​​<?php
$this->assign('my_comments',get_comments(10)); // 数据条数
?>
<ul>
<!--{foreach from=$my_comments item=comments name=id}-->
<li OnMouseOver="player('any{$smarty.foreach.id.iteration}');" onMouseOut="clocer('any{$smarty.foreach.id.iteration}');" style="cursor:hand;"><span>{$comments.add_time}</span>
<a href="goods-{$comments.id_value}.html" title="{$comments.content|escape:html}" target="_blank">{$comments.content|truncate:10:""}</a>
<div class="divbox">
<div id="any{$smarty.foreach.id.iteration}" class="more" OnMouseOver="player('any{$smarty.foreach.id.iteration}');" onMouseOut="clocer('any{$smarty.foreach.id.iteration}');">
<a href="goods-{$comments.id_value}.html" title="{$comments.content|escape:html}" target="_blank"><img src="{$comments.goods_thumb}" alt="{$comments.goods_name|escape:html}" width="120px" height="120px"/></a>
</div>
</div>
</li>
<!--{/foreach}-->
</ul>

本文标签:

很赞哦! ()

相关源码

  • (PC模板)工商公司注册会计财务记账pbootcms模板源码下载基于PbootCMS的工商财税行业网站系统,手工编写前端代码确保执行效率,双端自适应设计,支持后台实时更新服务价格和政策文件。查看源码
  • (自适应)光伏测试仪器电站运维设备网站源码免费下载本模板为光伏检测设备与电站运维服务企业设计,采用PbootCMS内核开发,具备完整的设备展示、技术文档管理及客户服务功能模块。通过自适应结构与SEO优化框架,有效提升企业在移动端和搜索引擎中的专业形象。查看源码
  • (自适应)刷卡pos机数据移动支付设备电子科技pbootcms模板下载本模板为POS机设备制造商、移动支付终端服务商和科技企业设计,基于PbootCMS系统开发,提供完整的在线展示平台解决方案,满足支付设备行业特有的展示需求。查看源码
  • (自适应html5)重工业钢铁机械设备网站pbootcms响应式模板下载为重工业领域打造的响应式网站模板,助力企业高效展示产品与服务,基于PbootCMS开发的工业级网站模板,特别适合钢铁制造、机械设备生产等重工业企业使用。查看源码
  • (自适应)工业机械制造设备网站pbootcms模板下载为机械制造、工业设备类企业设计,特别适合各类机械设备、生产线、工业自动化产品展示。采用响应式技术,确保在不同设备上都能清晰展示机械产品的技术参数和细节特点。查看源码
  • (PC+WAP)蓝色低碳环保隔断板装修装饰类网站pbootcms源码下载本款基于PbootCMS开发的网站模板为活动隔断板、装修装饰行业打造,特别适合移动隔断、环保隔断、办公分区等产品的展示与推广。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐