Application/Home/Controller/ArticleController.class.php的detail函数修改结果如下:

/* 文档模型详情页 */
public function detail($id = 0, $p = 1){
/* 标识正确性检测 */
if(!($id && is_numeric($id))){
$this->error('文档ID错误!');
}

/* 页码检测 */
$p = intval($p);
$p = empty($p) ? 1 : $p;

/* 获取详细信息 */
$Document = D('Document');
$info = $Document->detail($id);
if(!$info){
$this->error($Document->getError());
}
$content_array=explode('##分页##',$info['content']);
if(count($content_array)>1){
$info['content']=$content_array[$p-1];
$parse="";
for($i=1;$i<=count($content_array);$i++){
$parse.="<li><a href=".U('Article/detail',array('id'=>$info['id'],'page'=>$i)).">".$i."</a></li>";
}
$this->assign('page_string',$parse);
}

/* 分类信息 */
$category = $this->category($info['category_id']);

/* 获取模板 */
if(!empty($info['template'])){//已定制模板
$tmpl = $info['template'];
} elseif (!empty($category['template_detail'])){ //分类已定制模板
$tmpl = $category['template_detail'];
} else { //使用默认模板
$tmpl = 'Article/'. get_document_model($info['model_id'],'name') .'/detail';
}

/* 更新浏览数 */
$map = array('id' => $id);
$Document->where($map)->setInc('view');

/* 模板赋值并渲染模板 */
$this->assign('category', $category);
$this->assign('info', $info);
$this->assign('page', $p); //页码
$this->display($tmpl);
}

在后台添加文章的时候,在需要分页的地方插入   ##分页##

视图部分分页代码为:

<div class="pagination">
<ul>
{$page_string}
</ul>
</div>

基本思路:是把文章的content字段内容,分割为数组元素,根据传入p参数值的不同,显示数组不同的元素。

最新文章

  1. 【MSP是什么】MSP认证之项目集与项目群的关系和区别
  2. webstorm自动编译typescript
  3. 【Linux】/dev/null 2&gt;&amp;1 详解
  4. 在IE6下使用filter设置png背景
  5. plupload上传插件在SpringMVC中的整合
  6. 【Linux/Ubuntu学习5】Ubuntu 下android 开发,eclipse不能识别手机
  7. Extension Methods
  8. assert()用法
  9. SPOJ 375 树链剖分
  10. A*算法实现
  11. 控制结构(10): 指令序列(opcode)
  12. 用crontab部署定时任务
  13. 010Edit手写PE
  14. 用flask实现的分页
  15. 【转载】jdk1.8 LongAdder源码学习
  16. deepin中Tomcat添加执行权限
  17. Vue子组件调用父组件的方法
  18. mongodb 的一些基本命令以及 导入、导出,待更新
  19. LINUX CentOS7安装字体库
  20. Operating System-Thread(3)用户空间和内核空间实现线程

热门文章

  1. 如何使主机和虚拟机IP处于同一网段(内网渗透专用)
  2. POJ 1002 487-3279 (map )
  3. Linux eject弹出光驱
  4. python面向对象——类和对象
  5. Symfony2之创建一个简单的web应用 Symfony2——创建bundle
  6. request threaded-only IRQs with IRQF_ONESHOT【转】
  7. express 4.x+ swig
  8. [ Python - 4 ] python 装饰器
  9. xshell连接虚拟机CentOS出现eth0 device not found的解决方法
  10. poj 2242(已知三点求外接圆周长)