1、在library文件夹中建立一个名为index_comment.lbi文件

2、输入以下代码

 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?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 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']['time_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;
}
}
?>
<?php
$this->assign('my_comments',get_comments(8)); // 数据条数
?>
<div>
<h1> 顾客评论 </h1>
<div>
<!-- {foreach from=$my_comments item=comments} -->
<dl>
<dt><a href="goods.php?id={$comments.id_value}" target="_blank"><img src="{$comments.goods_thumb}" alt="" /></a></dt>
<dd><a href="goods.php?id={$comments.id_value}" style="color:#FF6400; font-weight:bold">名称:{$comments.goods_name}</a></dd>
<dd>{$comments.content|truncate:100:""}</dd>
<dd>时间:{$comments.add_time}</dd>
</dl>
<!-- {/foreach} -->
</div>
</div>

3、在index.dwt文件的评论的地方加入<!-- #BeginLibraryItem "/library/pl_y.lbi" -->  <!-- #EndLibraryItem -->

完成

最新文章

  1. python面试总结
  2. python之(re)正则表达式下
  3. Web jquery表格组件 JQGrid 的使用 - 8.Pager、新增数据、查询、刷新、查看数据
  4. 多线程下的 Lambda表达式 异步 WebClient 读取程序图标,来作为托盘 图标 logo ico
  5. Asp.Net Web API 2第九课——自承载Web API
  6. Kafka使用入门教程 简单介绍
  7. Codevs 1010 过河卒
  8. tomcat web.xml配置
  9. CentOS忘记root密码的解决方法
  10. JDK与Tomcat的联系
  11. Log4j.properties配置详细解读
  12. RemoteViews的内部机制
  13. Oracle-Linux安装配置python3.6环境
  14. Android SQLite 数据库学习
  15. centos6.5环境搭建openvp服务器及windows客户端搭建及配置详解
  16. 反射简化switch语句
  17. [javascript]jsonp-function 代码段
  18. Unity3D Animator控制参数和添加事件
  19. 定时任务的使用-crond
  20. PAT 甲级 1142 Maximal Clique

热门文章

  1. POJ 1940
  2. CPLD VS FPGA
  3. asp.net网站中添加百度地图功能
  4. sql 语句的各种连接
  5. http://blog.sina.com.cn/s/blog_5b9b4abe01017638.html
  6. lintcode: 堆化
  7. lintcode:线段树的查询
  8. iOS js oc相互调用(JavaScriptCore)(二)
  9. 转载网易博客:整理各大网站让网站变灰的css代码
  10. [AFN]AFNetworking错误总结