控制器中代码:
1 $demo=D(‘demo‘); 2 $count= $demo->count(); 3 $Page= new \Think\Page($count,9); 4 $Page->setConfig(‘header‘, ‘‘); 5 $Page->setConfig(‘prev‘,‘上页‘); 6 $Page->setConfig(‘next‘,‘下页‘); 7 $Page->setConfig(‘first‘,‘首页‘); 8 $Page->setConfig(‘last‘,‘末页‘); 9 // $Page->setConfig(‘theme‘, ‘%FIRST%%UP_PAGE%%LINK_PAGE%%DOWN_PAGE%%END%%HEADER%‘); 10 $show = $Page->show(); 11 $list = $demo->order(‘id‘)->limit($Page->firstRow.‘,‘.$Page->listRows)->select(); 12 $this->assign(‘list‘,$list); 13 $this->assign(‘page‘,$show); 14 $this->display();
模板代码:
<div class="newslist"> <ul> <foreach name="list" item="it"> <li> <a href="__URL__/newsshow/id/{$it.id}">{$it.title}</a></li> </foreach> </ul> </div> <div class="page"> {$page} </div>
时间: 2024-12-18 21:39:58