显示限制没有。 在笨分页页面链接(Show limited no. of page links

2019-08-03 02:51发布

我想显示一个有限没有。 页链接的,比方说5超过了10个链接,是有在笨任何已知的或尝试和测试方法来实现这一点。

因此可以说,用户现在可以看到以下链接

prev, 1(selected), 2, 3, 4, 5... next

用户点击,说4,现在他看到

prev... 3, 4(selected), 5, 6, 7...next

现在他点击7

prev... 6, 7(selected), 8, 9, 10...next

我怎样才能做到这一点的代码点火器?

提前致谢。

Answer 1:

有一个内置分页类此。



Answer 2:

找到分页类在库文件夹,然后编辑这个变量:

var $num_links


Answer 3:

这里是笨提供一个内置分页类。 您可以在用户手册中找到它。

在其中u要使用分页为零的函数定义开始索引变量。

public function pagination($start_index = 0)

{

  $result = $this->model->get_results($data); //this $data is the argument which you are passing to your model function. If you are using database to get results array.

  $items_per_page = 10;   //this is constant variable which you need to define

  $filtered_result = array_splice($result, $start_index, ITEM_PER_PAGE_USERS);

  $model['$filtered_result'] = $filtered_result;

  $total_rows = count($result);

  $model['page_links'] = create_page_links (base_url()."/controlelr_name/pagination",ITEM_PER_PAGE_USERS, $total_rows);

  $this->load->view('controller_name/view_file_name', $model);

}

 function create_page_links($base_url, $per_page, $total_rows) {

$CI = & get_instance();
$CI->load->library('pagination');

$config['base_url'] = $base_url;
$config['total_rows'] = $total_rows;
$config['per_page'] = $per_page; 

$CI->pagination->initialize($config); 

return $CI->pagination->create_links();

}

此创建页面链接功能是一个通用的功能.............更多解释检查分页从用户指导课......



Answer 4:

当你想固定修改分页页码$num_links

$config['total_rows'] =100;
$config["num_links"] = 5;
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['first_link'] = false;
$config['last_link'] = false;

它显示这样的:<< 2 3 4 5 6 7 >>



文章来源: Show limited no. of page links in codeigniter pagination