Mini pager

Public

Custom mini pager

</> CopyGet raw version
php
  1. /**
  2.  * Custom theme_views_mini_pager()
  3.  */
  4. function YOURTHEME_views_mini_pager($vars) {
  5. global $pager_page_array, $pager_total;
  6.  
  7. $tags = $vars['tags'];
  8. $element = $vars['element'];
  9. $parameters = $vars['parameters'];
  10. $quantity = $vars['quantity'];
  11.  
  12. // Calculate various markers within this pager piece:
  13. // Middle is used to "center" pages around the current page.
  14. $pager_middle = ceil($quantity / 2);
  15. // current is the page we are currently paged to
  16. $pager_current = $pager_page_array[$element] + 1;
  17. // max is the maximum page number
  18. $pager_max = $pager_total[$element];
  19. // End of marker calculations.
  20.  
  21. if ($pager_total[$element] > 1) {
  22.  
  23. $li_previous = theme('pager_previous',
  24. array(
  25. 'text' => (isset($tags[1]) ? $tags[1] : t('‹‹')),
  26. 'element' => $element,
  27. 'interval' => 1,
  28. 'parameters' => $parameters,
  29. )
  30. );
  31. if (empty($li_previous)) {
  32. $li_previous = "<span>&nbsp;</span>";
  33. }
  34.  
  35. $li_next = theme('pager_next',
  36. array(
  37. 'text' => (isset($tags[3]) ? $tags[3] : t('››')),
  38. 'element' => $element,
  39. 'interval' => 1,
  40. 'parameters' => $parameters,
  41. )
  42. );
  43.  
  44. if (empty($li_next)) {
  45. $li_next = "<span>&nbsp;</span>";
  46. }
  47.  
  48. $items[] = array(
  49. 'class' => array('pager-previous'),
  50. 'data' => $li_previous,
  51. );
  52.  
  53. $items[] = array(
  54. 'class' => array('pager-current'),
  55. 'data' => t('Page <span>@current</span> of @max', array('@current' => $pager_current, '@max' => $pager_max)),
  56. );
  57.  
  58. $items[] = array(
  59. 'class' => array('pager-next'),
  60. 'data' => $li_next,
  61. );
  62. return theme('item_list',
  63. array(
  64. 'items' => $items,
  65. 'title' => NULL,
  66. 'type' => 'ul',
  67. 'attributes' => array('class' => array('pager')),
  68. )
  69. );
  70. }
  71. }