ecshop自定义分页,评论分页
发布:smiling 来源: PHP粉丝网 添加日期:2015-09-28 15:41:54 浏览: 评论:0
首先建立三个文件,testp.php,test.dwt,test.lbi,test.php 就是最终的评论页面.
在test.php中加入以下内容:
- $page = isset($_REQUEST['page']) && intval($_REQUEST['page']) > 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']->sel ectLimit($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'];
- } //phpfensi.com
- return $arr;
- }
- function get_comments_count()
- {
- return $GLOBALS['db']->getOne('SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('comment'));
- }
test.dwt中引入 test.lbi 和 pages.lbi
test.lbi 中调用你的方法.
然后修改 includes\lib_main.php 大约509 后面加入以下代码:
- case 'test':
- $uri_args = array('page'=>$page, 'order' => $order);
- break;
最后把 test.php放入站点根目录,test.dwt放入模板目录,test.lbi放入对应模板的 库项目目录.
Tags: ecshop自定义分页 ecshop评论分页
- 上一篇:修复ecshop邮件模板无法保存html问题
- 下一篇:ECShop修改 自定义分页
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)