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

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

甘风力2023-12-15 21:40:13ecshop商城教程已有人查阅

导读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>

本文标签:

很赞哦! ()

留言与评论 (共有 条评论)
验证码:

本栏推荐

相关标签