分页不添加类
Posted
技术标签:
【中文标题】分页不添加类【英文标题】:Pagination not adding the class 【发布时间】:2015-07-19 17:23:02 【问题描述】:我正在使用分页,这是代码
$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">
?
【问题讨论】:
你在哪里告诉添加类分页?我想答案会解决你的问题。 【参考方案1】:代码中缺失
$config['full_tag_open'] = "<ul class='pagination'>";
$config['full_tag_close'] ="</ul>";
引导 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
【讨论】:
【参考方案2】:你必须改变你的完整标签开放数组元素
$config['full_tag_open'] = "<ul class='pagination'>";
【讨论】:
以上是关于分页不添加类的主要内容,如果未能解决你的问题,请参考以下文章