发现新版TP官网blog例子分页bug
时间:2011-05-08
来源:互联网
发现新版TP官网blog例子首页没有分页的bug
在BlogAction.class.php模块,我修正如下。分享给各位网友
public function index() {
$Blog = D("BlogView");
$count = $Blog->where("Blog.status=1")->count();//原先是 $count = $Blog->where("status=1")->count();,这样没有分页显示//
echo "Mikko-".$count;//修改之前 $count=''
$mode = "normal";
if (isset($_REQUEST["mode"])) {
$mode = $_REQUEST["mode"];
}
if ($mode == "list") {
$listRows = 45;
//$fields = 'id,title,categoryId,category,cTime,readCount,commentCount';
}else {
$listRows = 8;
//$fields = 'id,title,categoryId,cTime,readCount,commentCount,content,tags';
}
import("@.ORG.Page");
$p = new Page($count, $listRows);
$p->setConfig("header", "篇日志");
$this->assign("mode", $mode);
//以下红色代码也应该加上,否则不符合逻辑
$list = $Blog->where("Blog.status=1")->order("cTime desc")->limit($p->firstRow.','.$p->listRows)->select();
$page = $p->show();
$this->assign("list", $list);
$this->assign("page", $page);
//统计数据
$Blog = M("Blog");
$stat = array();
$stat["beginTime"] = $Blog->min('cTime');
$stat["blogCount"] = $Blog->where("status=1")->count();
$stat["readCount"] = $Blog->where("status=1")->sum("readCount");
$stat["commentCount"] = $Blog->where("status=1")->sum("commentCount");
$this->assign($stat);
$this->display();
}
作者: ymywmk 发布时间: 2011-05-08
我之前把它改成
复制代码
这样用的
- $condition['status']=1;
- $count = $Blog->where($condition)->count();
作者: yuqiguang 发布时间: 2011-05-08
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28