codeigniter分页:在最后一页按钮之前显示DOTS(。)

时间:2013-05-06 13:32:23

标签: php codeigniter pagination

    $pagination_config['per_page'] = 10; 
    $pagination_config['total_rows'] = 100; 
    $pagination_config['anchor_class'] = 'class="page gradient"';
    $pagination_config['cur_tag_open'] = '<a class="page active">';
    $pagination_config['cur_tag_close'] = '</a>';
    $pagination_config['full_tag_open'] = '<div class="pagination">';
    $pagination_config['full_tag_close'] = '</div>';
    $pagination_config['first_link'] = 'First';
    $pagination_config['last_link'] = 'Last';
    $pagination_config['num_links'] = 5;

所以这很好用 但正如你所看到我只在我的页面中显示5页码 如果有超过5页,我想在最后一页按钮之前显示几个点

1 2 3 4 5... Lastpage

现在就是这样

1 2 3 4 5 Lastpage

我该怎么做?

2 个答案:

答案 0 :(得分:1)

$pagination_config['per_page'] = 10; 
$pagination_config['total_rows'] = 100; 
$pagination_config['anchor_class'] = 'class="page gradient"';
$pagination_config['cur_tag_open'] = '<a class="page active">';
$pagination_config['cur_tag_close'] = '</a>';
$pagination_config['full_tag_open'] = '<div class="pagination">';
$pagination_config['full_tag_close'] = '</div>';
$pagination_config['first_link'] = 'First';
$pagination_config['num_links'] = 5;

if(ceil($pagination_config['total_rows']/$pagination_config['per_page'])> 5)
    $pagination_config['last_link']    =   '.... Last';
else 
    $pagination_config['last_link']    =   'Last';

只需检查页码是否大于5.简单。

答案 1 :(得分:0)

这会有用吗?

$config['last_link'] = '...Lastpage';