博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ECSHOP增加独立评论页面,并分页显示
阅读量:4599 次
发布时间:2019-06-09

本文共 2238 字,大约阅读时间需要 7 分钟。

ecshop使用一个单独的页面来显示所有的评论,并在评论中显示会员 评论的商品 评论内容等。

修改方法。

首先建立三个文件,testp.php  test.dwt   test.lbi,test.php 就是最终的评论页面。

在test.php中加入以下内容

0 ? intval($_REQUEST['page']) : 1;$size = 15; $count = get_comments_count(); $max_page = ($count> 0) ? ceil($count / $size) : 1; if ($page > $max_page) { $page = $max_page; } $goodslist = get_comments($size, $page); $smarty->assign('my_comments', $goodslist); assign_pager( 'test', '', $count, $size, '', $order, $page,'', '', '', '', '','', '', ''); assign_dynamic('test');$smarty->display('test.dwt');function get_comments($size, $page){ $display = $GLOBALS['display']; /* 获得评论列表 */ $sql = 'SELECT a.*,b.goods_id,b.goods_name,user_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'; $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); $arr = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { $arr[$row['comment_id']]['type'] = $row['goods_type']; $arr[$row['comment_id']]['add_time'] = local_date($GLOBALS['_CFG']['time_format'], $row['add_time']); $arr[$row['comment_id']]['content'] = $row['content']; $arr[$row['comment_id']]['id_value'] = $row['id_value']; $arr[$row['comment_id']]['goods_name'] = $row['goods_name']; $arr[$row['comment_id']]['user_name'] = $row['user_name']; } return $arr;}function get_comments_count(){ return $GLOBALS['db']->getOne('SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('comment'));}?>

 

test.dwt中写入以下内容

test.lbi 中写入以下内容

"游客"
"{$comments.user_name}"
在{$comments.add_time} 评论 "{$comments.goods_name}":
"{$comments.content}"

 

然后修改 includes\lib_main.php 大约509 后面加入以下代码

case 'test':            $uri_args  = array('page'=>$page, 'order' => $order);            break;

 

最后把 test.php放入站点根目录,test.dwt放入模板目录,test.lbi放入对应模板的

库项目目录。
访问test.php就可以看到评论已经显示
并可以分页了,这里只是介绍了程序的实现方法,模板中并未引入头部和底部的模板也没有为评论显示设计样式。在实际使用时可根据具体的网站来来设计评论显示的样式。

 

转载于:https://www.cnblogs.com/wangblognet/archive/2012/12/25/2832922.html

你可能感兴趣的文章
[leetcode]35.Search Insert Position
查看>>
xshell鼠标文本设置
查看>>
java中连接各种数据的方法
查看>>
移动端网页头部标签模板
查看>>
每日一练3
查看>>
SaltStack系列(二)之常用模块
查看>>
Day4
查看>>
OpenMobile's Application Compatibility Layer (ACL)
查看>>
html中文件类型的accept属性有哪些
查看>>
JS及JQuery对Html内容编码,Html转义
查看>>
Coursera公开课笔记: 斯坦福大学机器学习第十课“应用机器学习的建议(Advice for applying machine learning)”...
查看>>
竞价广告系统-广告检索
查看>>
强哥PHP面向对象学习笔记
查看>>
[转]基于.NET平台常用的框架整理
查看>>
Symbian (Read Inbox)读取收件箱的内容
查看>>
良好的编程规范
查看>>
struts2 入门
查看>>
.net 编译原理
查看>>
mean 快速开发和现有技术的对比分析
查看>>
Metro Style app :浏览器扩展
查看>>