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

本文标签:

很赞哦! ()

相关源码

  • 帝国CMS7.5H5小游戏模板游戏攻略下载网整站源码本模板基于帝国CMS系统开发,为H5小游戏和APP应用资讯类网站设计。模板架构针对小游戏行业特点优化,支持游戏发布、资讯分享、应用推荐等功能,满足各类小游戏门户网站的建设需求。查看源码
  • 帝国cms7.5奇闻异事末解之谜模板免费下载带数据本模板基于帝国CMS7.5系统开发,为神秘现象、未解之谜类主题网站设计。包含完整的PC端、移动端及百度MIP站同步生成功能,内置火车头采集规则模块,可快速采集目标站内容资源。整体设计风格神秘大气,符合主题定位。查看源码
  • (PC+WAP)五金机械设备营销型模板下载带在线留言为机械设备制造商设计的营销型模板,集成产品参数对比系统、产品展示模块和询价管理功能。采用PbootCMS开发内核,PHP7+运行环境。手工编写语义化HTML5结构,CSS3动画优化交互体验。查看源码
  • (自适应)pbootcms模板五金元件气缸气动系统源码下载基于PbootCMS核心开发的气缸气动系统网站模板,为五金元件、气动设备制造企业设计。采用响应式布局技术,自动适配手机、平板等移动设备,确保各类终端用户获得良好浏览体验。查看源码
  • 帝国cms7.5品牌连锁店招商加盟商机网站模版源码本模板为招商加盟、创业投资、品牌连锁等商业领域设计,采用帝国CMS7.5内核构建,整体风格简洁大气,突出商业信任感与专业度,适合各类招商加盟项目展示、品牌连锁店宣传等商业应用场景。查看源码
  • 自适应营销型IT网络工作室互联网建站公司pbootcms网站模板为IT网络服务商、建站企业打造的高性能营销门户,基于PbootCMS开源内核深度开发采用HTML5自适应架构,实现PC与手机端数据实时同步交互。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐