我需要一点帮助,
我想使用分页 CodeIgniter。
这是我用于显示分页的代码。
$this->load->library("pagination");
$config = array();
$key = $this->input->get_post('qfront');
$config["base_url"] = base_url() . "source/";
$config["total_rows"] = $this->fetch_count($key)->count;
$config["per_page"] = 10;
$choice = $config["total_rows"] / $config["per_page"];
$config["uri_segment"] = 2;
$config["num_links"] = round($choice);
$config['full_tag_open'] = '<div class="pagination"><ul>';
$config['full_tag_close'] = '</ul></div><!--pagination-->';
$config['first_link'] = '« First';
$config['first_tag_open'] = '<li class="prev page">';
$config['first_tag_close'] = '</li>';
$config['last_link'] = 'Last »';
$config['last_tag_open'] = '<li class="next page">';
$config['last_tag_close'] = '</li>';
$config['next_link'] = 'Next →';
$config['next_tag_open'] = '<li class="next page">';
$config['next_tag_close'] = '</li>';
$config['prev_link'] = '← Previous';
$config['prev_tag_open'] = '<li class="prev page">';
$config['prev_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li class="page">';
$config['num_tag_close'] = '</li>';
$this->pagination->initialize($config);
$page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;
$data["results"] = $this->fetch_result($config["per_page"], $page, $key);
$data["links"] = $this->pagination->create_links();
$data["key"] = $key;
$this->load->view("page", $data);
在我看来:
<?php echo $links; ?>
我得到的是
我怎样才能像<-prev 1 2 3 4 5 一样。 。 。 200 下一个->
这可能吗?或者也许是一些漂亮的 css
最佳答案
在传递给分页initialize()
方法的$config
数组中,您可以使用设置当前页面两侧显示的链接数量>num_links
:
$config['num_links'] = 2;
来自CI user guide :
The number of "digit" links you would like before and after the selected page number. For example, the number 2 will place two digits on either side, as in the example links at the very top of this page.
这应该会让你更接近你想要的。我不知道这个库生成的确切 HTML,所以如果你发布它,也许有人可以给你一个 CSS 解决方案。您还可以查看extending the CI pagination library以满足您的需求(查看“扩展 native 库”)。
关于php - 在 codeigniter 中用于分页的自定义 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20573882/