分类分类
更新时间:2026-05-11 01:07:51作者:fang
今天给大家介绍一篇文章,是关于ECShop首页调用最新评论+(增加显示评论时间),分享给大家供大家参考。具体如下:
在库目录里增加一个文件:index_comments.lbi 里面有内容如下:
<?php
if(!function_exists("get_comments")){
function get_comments($num)
{
$sql = 'SELECT * FROM '. $GLOBALS['ecs']->table('comment') .
' WHERE status = 1 AND parent_id = 0 and comment_type=0 '.
' ORDER BY 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'] = $comments[$idx]['add_time'] = local_date
($GLOBALS['_CFG']['time_format'], $row['add_time']);
$comments[$idx]['user_name'] = $row['user_name'];
$comments[$idx]['content'] = $row['content'];
$comments[$idx]['id_value'] = $row['id_value'];
}
return $comments;
}
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--数据调用-最新评论开始 -->
<?php
$this->assign('my_comments',get_comments(10)); // 10条数据
?>
<div class="comments">
<!--{foreach from=$my_comments item=comments}-->
<div class="t_l f_l"><a href="goods.php?id={$comments.id_value}" target="_blank">
{$comments.content|truncate:15:""}</a></div><div class="d_r f_r">时间:
{$comments.add_time}</div>
<!--{/foreach}-->
</div>
首页调用这个库文件就OK了.
<!-- #BeginLibraryItem "/library/index_comments.lbi" --> <!-- #EndLibraryItem -->
以上就是本文章的内容,希望对大家有所帮助
相关
修真情缘角色扮演303.33 MBv1.0.02026-05-10
下载我的小独角兽女孩休闲益智380.89 MBv1.0.232026-05-10
下载超级种田男孩手机版经营养成1.31Gv1.0.92026-05-10
下载不必要的实验冒险游戏64.9 MBv1.1.592026-05-10
下载军师联盟策略游戏163.2 MBv0.0.12026-05-10
下载翻天喜地凑大钱手机版休闲益智138.72 MBv1.0.92026-05-10
下载东离剑游纪手游动作射击1.6Gv1.4.22026-05-10
下载天猫养车商家版App学习办公74.95 MBv0.6.12026-05-10
下载掌上命运方舟App手游辅助137.48 MBv1.9.12026-05-10
下载退役军人服务APP生活服务67.16 MBv1.2.52026-05-10
下载屯漫漫画APP资讯阅读23.06 MBv2.0.32026-05-10
下载蛋仔派对蛋壳App手游辅助185.73 MBv0.0.22026-05-10
下载









