|
效果:
链接地址形如:http://localhost/page_1.htm
附件下载后解压到application/library/
说明:示例使用的.html, 是伪静态方式,还需要做uri路由
继承CI的分页类,覆盖了一些成员变量,添加了两个成员变量,重写了方法 create_links.
添加的成员变量
PHP复制代码 var $base_word = "page_";
var $file_ext = ".shtml";
复制代码
示例代码
PHP复制代码
function newslist (){
$config['base_url'] = '/admin';
$config['full_tag_open'] = '<style>#slink{font-size:12px;color:#333;}#slink a {color:#333;text-decoration:none;}#slink a:hover{color:red;}</style><span id="slink">';
$config['full_tag_close'] = '</span>';
$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);
}
复制代码
[ 本帖最后由 yygcom 于 2008-8-3 16:45 编辑 ] |
评分
-
查看全部评分
|