How to display Yii's CLinkPager first and last buttons

巧了我就是萌 提交于 2020-01-07 06:15:13

问题


My page number is like:

Page:1 2 3 4 5 last

But I want to change it like:

<< first | < previous | 1 | ... | 5 | next > | last >>

How to change this?

My code is:

<?php
$this->widget('CLinkPager', array(
    'currentPage' => $pages->getCurrentPage(),
    'itemCount' => $item_count,
    'pageSize' => $page_size,
    //'linkHash'=>'ls',
    'maxButtonCount' => 5,
    'firstPageLabel' => '',
    'prevPageLabel' => '',
    'nextPageLabel' => '',
    'lastPageLabel' => 'last',
    'header' => '<p>Page:</p>',
    /*'pager'=>array(
    'class'=>'MyLinkPager',
    'linkHash'=>'test'
    ),*/

    'htmlOptions' => array(
        'class' => 'pages'
    )
)); ?> 

回答1:


Try this

<?php
   $this->widget('CLinkPager', array(
      'currentPage' => $pages->getCurrentPage(),
      'itemCount' => $item_count,
      'pageSize' => $page_size,
      //'linkHash'=>'ls',
     'maxButtonCount' => 5,
     'selectedPageCssClass'=>'active',
     'hiddenPageCssClass'=>'disabled',
     'firstPageCssClass'=>'previous',
     'firstPageLabel' => '<< first | ',
     'prevPageLabel' => 'previous |',
     'nextPageLabel' => ' | next',
     'lastPageLabel' => ' | last >>',
     'header' => '<p>Page:</p>',
     /*'pager'=>array(
       'class'=>'MyLinkPager',
'      linkHash'=>'test'
     ),*/

  'htmlOptions' => array(
    'class' => 'pages'
  )
)); ?> 



回答2:


In this case you need to set a page labels. You can use this instead of yout current definition:

'firstPageLabel' => '&laquo;&laquo; first',
'prevPageLabel' => '&laquo; previus',
'nextPageLabel'=>'next &raquo;',
'lastPageLabel'=>'last &raquo;&raquo;',
'maxButtonCount' => 5

To style a vertical separator you can use a css:

'cssFile' => Yii::app()->request->baseUrl . '/css/your_pager_css.css',

Place new css file to css dir and define a needed styles of a pager.

Some ideas: http://www.yiiplayground.com/index.php?r=UiModule/pagination/basicPager

How to customize Yii CGridView Pager?



来源:https://stackoverflow.com/questions/32309706/how-to-display-yiis-clinkpager-first-and-last-buttons

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!