I need to mark active page menu item in block with all pages list, for example, as bold.
But I can't find any css style for active page item, all of pages have an 'active' css style on a tag!
Will be good to add "current" css tag additional to "active" for ability to restyle active page via css.

Comments

zoo’s picture

Hi,

needing this feature, it would be nice if the current page were highlighted in the block.

Or... maybe the solution is another?

jenlampton’s picture

Status: Active » Needs review
StatusFileSize
new3.28 KB

Attached is a patch that adds a pager-curent class to the active link in the paging block.

jimmyko’s picture

You can override the theme_pager_link function in your theme. Below is what I have done in the website I work on.

/**
 * Override theme_pager_link
 *
 * Add class to current pager item.
 */
function customtheme_pager_link($text, $page_new, $element, $parameters = array(), $attributes = array()) {
  if (!empty($text)) {
    $matches = array();
    preg_match('/\d$/', $text, $matches);
    $text = $matches[0];
  }

  $page = isset($_GET['page']) ? $_GET['page'] : '';
  if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
    $parameters['page'] = $new_page;
  }

  $query = array();
  if (count($parameters)) {
    $query[] = drupal_query_string_encode($parameters, array());
  }
  $querystring = pager_get_querystring();
  if ($querystring != '') {
    $query[] = $querystring;
  }

  // add class for styling.
  $current = FALSE;
  if ($page == $parameters['page']) {
    $current = TRUE;
  } else if (empty($page) && $parameters['page'] == '0,0') {
    $current = TRUE;
  }
  if ($current) {
    $attributes['class'] = 'pager-current';
  }

  // Set each pager link title
  if (!isset($attributes['title'])) {
    static $titles = NULL;
    if (!isset($titles)) {
      $titles = array(
        t('« first') => t('Go to first page'),
        t('‹ previous') => t('Go to previous page'),
        t('next ›') => t('Go to next page'),
        t('last »') => t('Go to last page'),
      );   
    }    
    if (isset($titles[$text])) {
      $attributes['title'] = $titles[$text];
    }    
    else if (is_numeric($text)) {
      $attributes['title'] = t('Go to page @number', array('@number' => $text));
    }    
  }

  return l($text, $_GET['q'], array('attributes' => $attributes, 'query' => count($query) ? implode('&', $query) : NULL));
}
nancydru’s picture

Issue summary: View changes
Status: Needs review » Needs work

Patch does not apply.

nancydru’s picture

Status: Needs work » Fixed

The patch in #2 seems to have been committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.