Всем привет, захотелось немного изменить функцию в drupal, очень не устраивала пустая кнопка на первом и последнем значении пагинатора.
Вылечил добавив простую логику:
if (empty($li_previous)) { $class_prev = 'hide'; }else{ $class_prev = 'pager-previous'; }
function mobile_tablet_views_mini_pager($vars) { //Переделываем мини pagers global $pager_page_array, $pager_total; $tags = $vars['tags']; $element = $vars['element']; $parameters = $vars['parameters']; // current is the page we are currently paged to $pager_current = $pager_page_array[$element] + 1; // max is the maximum page number $pager_max = $pager_total[$element]; // End of marker calculations. if ($pager_total[$element] > 1) { $li_previous = theme('pager_previous', array( 'text' => (isset($tags[1]) ? $tags[1] : t('‹‹')), 'element' => $element, 'interval' => 1, 'parameters' => $parameters, ) ); if (empty($li_previous)) { $class_prev = 'hide'; }else{ $class_prev = 'pager-previous'; } $li_next = theme('pager_next', array( 'text' => (isset($tags[3]) ? $tags[3] : t('››')), 'element' => $element, 'interval' => 1, 'parameters' => $parameters, ) ); if (empty($li_next)) { $class_next = 'hide'; }else{ $class_next = 'pager-next'; } $items[] = array( 'class' => array(<strong>$class_prev</strong>), 'data' => $li_previous, ); $items[] = array( 'class' => array('pager-current'), 'data' => t('@current of @max', array('@current' => $pager_current, '@max' => $pager_max)), ); $items[] = array( 'class' => array(<strong>$class_next</strong>), 'data' => $li_next, ); return theme('item_list', array( 'items' => $items, 'title' => NULL, 'type' => 'ul', 'attributes' => array('class' => array('pager')), ) ); } }
если есть вопросы по работе функции, сбрасывайте их в комментарии
Добавить комментарий