您现在的位置是:首页 > 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>

本文标签:

很赞哦! ()

相关源码

  • 响应式粉色美容整形化妆品pbootcms网站模板开源源码该网站模板为美容整形、化妆品企业设计,采用响应式布局确保在手机、平板及PC端自动适配显示效果。基于PbootCMS内核开发,支持一键替换图文内容快速转换至其他行业应用。查看源码
  • pbootcms模板(自适应手机版)红色响应式单位机构类网站自适应响应式单位机构网站模板 | PbootCMS内核开发为机构组织设计的响应式网站模板,采用PbootCMS内核开发,支持一键替换行业内容,满足多元化场景需求。查看源码
  • (响应式)wordpress模板VieuV4.5主题资讯自媒体博客源码Vieu主题专注于个人博客与企业展示场景,采用响应式设计确保在手机、电脑、平板等多设备上的展示。主题集成会员中心、投稿系统、内容保护等实用功能,满足现代博客网站的建设需求。查看源码
  • (PC+WAP)高端餐饮美食小吃加盟网站模板下载pbootcms本模板基于PbootCMS内核开发,为餐饮美食品牌加盟、小吃连锁企业量身打造。通过精致的美食视觉呈现与加盟业务流程展示,帮助餐饮企业建立专业线上门户,实现品牌形象与加盟业务的双重展示。查看源码
  • 帝国cms淘宝客京东联盟网站整站源码下载本模板基于帝国CMS内核深度开发,为淘宝客行业量身定制。随着腾讯微信与淘宝生态的互联互通,淘宝客链接现可在微信、QQ等平台直接分享,为推广带来更多便利。模板特别优化了店铺推广功能,有效避免商品下架导致的链接失效问题,同时支持京东联盟等多平台商品推广。查看源码
  • (自适应响应式)高端简繁双语HTML5金融资本咨询单页pbootcms模板采用响应式设计确保在各类手机端设备很好的呈现。该模板专注于金融咨询、资本管理等领域企业形象展示,通过结构化布局突出行业专业度与可信度,后台数据同步管理简化内容维护流程。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐