原文 http://codeigniter.org.cn/forums/viewthread.php?tid=877&highlight=%E5%88%86%E9%A1%B5
链接地址形如:http://localhost/page_1.htm
附件下载后解压到application/library/
说明:示例使用的.html, 是伪静态方式,还需要做uri路由
继承CI的分页类,覆盖了一些成员变量,添加了两个成员变量,重写了方法 create_links.
添加的成员变量
复制内容到剪贴板PHP 代码:
var $base_word = “page_”;
var $file_ext = “.shtml”;
示例代码
function newslist(){
$config[‘base_url’] = ‘/admin’;
$config[‘full_tag_open’] = ‘
‘;
$config[‘full_tag_close’] = ‘‘;
$config[‘per_page’] = 15;
$config[‘uri_segment’] = 2;
$config[‘base_word’] = ‘newslist_’;
/*for($i=0;$i<7;$i++){
echo $i.'='.$this->uri->segment($i);
}*/
preg_match (“/newslist_(d*)_(d*)/i”, $this->uri->segment($config[‘uri_segment’]),$mm);
if(!isset($mm[1])){show_error(‘err’);exit;}
$config[‘cur_page’] = $mm[1];
$cid = $mm[2];
$this->db->where(‘cid’,$cid);
$this->db->from(‘news’);
$config[‘total_rows’] = $this->db->count_all_results();
$config[‘file_ext’] = ‘_’.$cid.’.html’;
$query = $this->news_admin_model->get_news($cid,$config[‘per_page’],$mm[1]);
$data[‘results’] = $query->result(); //$data[‘results’] = $query -> result_array();
$query = $this->news_admin_model->get_newscate();
$data[‘cates’] = $query->result();
$this->pagination->initialize($config);
$data[‘cid’] = $cid;
$this->load->view(‘admin/news_view’,$data);
}