我正在使用Codeigniter分页类进行分页。我当前的配置变量是:
$config['base_url'] = base_url('admin/sub_categories');
$config['total_rows'] = $this->sub_categories_model->get_count();
$config['base_url'] = "";
$config['total_rows'] = "";
$config['per_page'] = 30;
$config['first_link'] = 'Эхнийх';
$config['last_link'] = 'Сүүлийх';
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['first_link'] = false;
$config['last_link'] = false;
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['prev_link'] = '«';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = '»';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
然后在每个控制器上使用它都使用太多行。所以我在config /文件夹下创建了pagination.php。然后把上面的代码。然后加载它像:
$this->config->load('pagination', TRUE);
$this->pagination->initialize($this->config->item('pagination'));
现在你看,我的问题是$config['base_url']
,而$config['total_rows']
在每个控制器上都有所不同。如何在加载后更改其值?
答案 0 :(得分:2)
如果我理解你,那么你可以试试这个:
$this->config->load('pagination', TRUE);
$conf = $this->config->item('pagination');
$conf['base_url'] = base_url('admin/sub_categories');
$conf['total_rows'] = $this->sub_categories_model->get_count();
$this->pagination->initialize($conf);
您应该在每个要使用的paginator
base_url
和total_rows