我正在使用分页,这是代码
$this->load->library('pagination');
$config['first_link'] = 'First';
$config['first_tag_close'] = '</div>';
$config['last_link'] = 'Last';
$config['last_tag_open'] = '<div>';
$config['last_tag_close'] = '</div>';
$config['full_tag_open'] = '<ul>';
$config['full_tag_close'] = '</ul>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a>';
$config['cur_tag_close'] = '</a></li>';
$config['base_url'] = base_url().'blog';
$config['total_rows'] = $Count;
$config['per_page'] = 2;
$this->pagination->initialize($config);
并使用
echo $this->pagination->create_links();
调用分页。
但是课程class="pagination"
没有为<ul>
添加。
我只在页面源中获得以下内容
<ul><a href="http://localhost/blog" data-ci-pagination-page="0"><</a><li><a href="http://localhost/blog" data-ci-pagination-page="0">1</a></li><li class="active"><a>2</a></li><li><a href="http://localhost/blog/4" data-ci-pagination-page="4">3</a></li><a href="http://localhost/blog/4" data-ci-pagination-page="4">></a></ul>
那么,我如何让班级出现,以便我可以<ul class="pagination">
?
答案 0 :(得分:1)
您必须更改完整标记打开数组元素
$config['full_tag_open'] = "<ul class='pagination'>";
答案 1 :(得分:1)
在您的代码中遗漏
$config['full_tag_open'] = "<ul class='pagination'>";
$config['full_tag_close'] ="</ul>";
Bootstrap Codeigniter分页
$this->load->library('pagination');
$config['base_url'] = base_url('blog');
$config['total_rows'] = $this->db->count_all('blog');
$config['uri_segment'] = 2;
$config['per_page'] = 8;
$config['page_query_string'] = TRUE;
$config['num_links'] = "16";
$config['full_tag_open'] = "<ul class='pagination'>";
$config['full_tag_close'] ="</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['last_tagl_close'] = "</li>";
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
Codeigniter Pagination Library User Guide
在config / route.php
中设置第二个路由$route['blog'] = "blog"; May need blog/index
$route['blog/(:any)'] = "blog/$1"; May need blog/index