diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-08-29 16:16:50 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-08-29 16:16:50 +0000 |
commit | ffdfe048580748a9dbcfdfdc3bf8c0b0b7f6bddb (patch) | |
tree | 06f7075de9ecd52c9cdfbaa67ad48b94f487caa0 | |
parent | 118e91cc4048905446ee46fa87af60a96c996c8e (diff) | |
download | brdo-ffdfe048580748a9dbcfdfdc3bf8c0b0b7f6bddb.tar.gz brdo-ffdfe048580748a9dbcfdfdc3bf8c0b0b7f6bddb.tar.bz2 |
#103391 by m3avrck, RobRoy and dvessel: cleanup active list item classes
-rw-r--r-- | includes/theme.inc | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/includes/theme.inc b/includes/theme.inc index c9e41401e..026ce50ac 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1096,27 +1096,19 @@ function theme_links($links, $attributes = array('class' => 'links')) { $i = 1; foreach ($links as $key => $link) { - $class = ''; + $class = $key; - // Automatically add a class to each link and also to each LI - if (isset($link['attributes']) && isset($link['attributes']['class'])) { - $link['attributes']['class'] .= ' '. $key; - $class = $key; - } - else { - $link['attributes']['class'] = $key; - $class = $key; - } - - // Add first and last classes to the list of links to help out themers. - $extra_class = ''; + // Add first, last and active classes to the list of links to help out themers. if ($i == 1) { - $extra_class .= 'first '; + $class .= ' first'; } if ($i == $num_links) { - $extra_class .= 'last '; + $class .= ' last'; + } + if ($link['href'] == $_GET['q']) { + $class .= ' active'; } - $output .= '<li class="'. $extra_class . $class .'">'; + $output .= '<li class="'. $class .'">'; if (isset($link['href'])) { // Pass in $link as $options, they share the same keys. @@ -1127,7 +1119,11 @@ function theme_links($links, $attributes = array('class' => 'links')) { if (empty($link['html'])) { $link['title'] = check_plain($link['title']); } - $output .= '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>'; + $span_attributes = ''; + if (isset($link['attributes'])) { + $span_attributes = drupal_attributes($link['attributes']); + } + $output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>'; } $i++; |