我在codeigniter中遇到分页问题。单击第二页时,将加载信息。但页面活动是一个,而不是两个。谁能帮助我?
这是我的代码:
在我的配置分页中
$config['pagination']['full_tag_open']='<div class="row"><div class="col-xs-12"><div class="dataTables_paginate paging_bootstrap"><ul class="pagination pull-right">';
$config['pagination']['full_tag_close']='</ul></div></div></div>';
$config['pagination']['first_link']='← Trang đầu';
$config['pagination']['first_tag_open']='<li class="prev disabled">';
$config['pagination']['first_tag_close']='</li>';
$config['pagination']['last_link']='Trang cuối';
$config['pagination']['last_tag_open']='<li>';
$config['pagination']['last_tag_close']='</li>';
$config['pagination']['next_link']='Trang sau → ';
$config['pagination']['next_tag_open']='<li class="next">';
$config['pagination']['next_tag_close']='</li>';
$config['pagination']['prev_link']='← Trang trước';
$config['pagination']['prev_tag_open']='<li class="prev">';
$config['pagination']['pre_tag_close']='</li>';
$config['pagination']['cur_tag_open']='<li class="active"><a>';
$config['pagination']['cur_tag_close']='</a></li>';
$config['pagination']['num_tag_open']='<li>';
$config['pagination']['num_tag_close']='</li>';
$config['pagination']['use_page_numbers'] = TRUE;
$config['pagination']['per_page'] = 5;
$config['pagination']['num_link']=7;
$config['pagination']['uri_segment']=4;
在控制器中
$this->load->library('pagination');
$config = $this->config->item('pagination');
$config['base_url'] = $this->config->base_url('admin/posts/view');
$config['total_rows'] = $this->Model_posts->total(array('site_id'=>$this->site_id));
$total_page=ceil($config['total_rows']/$config['per_page']);
$page = ($page>$total_page)?$total_page:$page;
$page = ($page<1)?1:$page;
$page = $page-1;
$config['pagination']['cur_page'] = $page;
$this->pagination->initialize($config);
$data['list_paginition'] = $this->pagination->create_links();
if($config['total_rows']>0){
$data['list_posts'] = $this->Model_posts->view(($page*$config['per_page']),$config['per_page']);
}
在我的模特中
public function view($start,$limit){
return $this->db->select('utt_post.id,utt_post.title,utt_post.description,utt_post.detail,utt_post.image,utt_post.status,utt_post.time_create,utt_post.time_update,utt_cate.title as catetitle,utt_users.username')->from('utt_post')->JOIN('utt_users','utt_users.id = utt_post.user_id')->JOIN('utt_cate','utt_cate.id = utt_post.cate_id')->where('utt_post.status < ','3')->where('utt_post.status > ','0')->where('post_type','news')->where('utt_post.site_id = ',$this->site_id)->ORDER_BY('utt_post.id DESC')->limit($limit,$start)->get()->result_array();}