How to change the look of a pager result set?
<div>
You can copy theme_pager() (http://api.drupal.org/api/function/theme_pager/5) and paste it in your theme's template.php file, then rename it to _pager() or phptemplate_pager() and change its behavior, as either of those versions of the theme_pager() function will be called before the default theme_pager() function found in core.</div>
<?php
function phptemplate_pager($tags = array(), $limit = 10, $element = 0, $parameters = array()) {
global $pager_total;
$output = '';
$output .= '<div class="pager centered">'; //Here's where I made the change
$output .= theme('pager_first', ($tags[0] ? $tags[0] : t('« first')), $limit, $element, $parameters);
$output .= theme('pager_previous', ($tags[1] ? $tags[1] : t('‹ previous')), $limit, $element, 1, $parameters);
$output .= theme('pager_list', $limit, $element, ($tags[2] ? $tags[2] : 9 ), '', $parameters);
$output .= theme('pager_next', ($tags[3] ? $tags[3] : t('next ›')), $limit, $element, 1, $parameters);
$output .= theme('pager_last', ($tags[4] ? $tags[4] : t('last »')), $limit, $element, $parameters);
$output .= '</div>';
}
}
?>
function phptemplate_pager($tags = array(), $limit = 10, $element = 0, $parameters = array()) {
global $pager_total;
$output = '';
if (
$pager_total[$element] > 1) {$output .= '<div class="pager centered">'; //Here's where I made the change
$output .= theme('pager_first', ($tags[0] ? $tags[0] : t('« first')), $limit, $element, $parameters);
$output .= theme('pager_previous', ($tags[1] ? $tags[1] : t('‹ previous')), $limit, $element, 1, $parameters);
$output .= theme('pager_list', $limit, $element, ($tags[2] ? $tags[2] : 9 ), '', $parameters);
$output .= theme('pager_next', ($tags[3] ? $tags[3] : t('next ›')), $limit, $element, 1, $parameters);
$output .= theme('pager_last', ($tags[4] ? $tags[4] : t('last »')), $limit, $element, $parameters);
$output .= '</div>';
return
$output;}
}
?>
- navdeep's blog
- login or register to post comments