用于在codeigniter中进行分页的自定义css

时间:2013-12-13 18:51:53

标签: php html css codeigniter pagination

我需要一点帮助,

我想使用分页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'] = '&laquo; First';
    $config['first_tag_open'] = '<li class="prev page">';
    $config['first_tag_close'] = '</li>';

    $config['last_link'] = 'Last &raquo;';
    $config['last_tag_open'] = '<li class="next page">';
    $config['last_tag_close'] = '</li>';

    $config['next_link'] = 'Next &rarr;';
    $config['next_tag_open'] = '<li class="next page">';
    $config['next_tag_close'] = '</li>';

    $config['prev_link'] = '&larr; 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; ?>

我得到的是 enter image description here

我怎么能像&lt; -prev 1 2 3 4 5那样。 。 。 200 next-&gt;

有可能吗?或者可能是一个不错的CSS:D(我在css&gt;中非常愚蠢,&lt;)

1 个答案:

答案 0 :(得分:2)

在传递到分页$config方法的initialize()数组中,您可以使用num_links设置当前页面任一侧显示的链接数量:

$config['num_links'] = 2;

来自CI user guide

  

您在所选页码之前和之后想要的“数字”链接数。例如,数字2将在两侧放置两个数字,如本页顶部的示例链接所示。

这应该让你更接近你想要的。我不知道这个库生成的确切HTML,所以如果你发布它可能有人可以给你一个CSS解决方案。您还可以查看extending the CI pagination library以满足您的需求(请查看“扩展本机库”)。