By Olivaw on
I want to override the theme_links() function but only for the 'node' part of the page rather than every single menu item on the page.
This is my code in the template.php at the moment (I've commented my changes):
function bsc_theme_links($variables) {
$links = $variables['links'];
$attributes = $variables['attributes'];
$heading = $variables['heading'];
global $language_url;
$output = '';
if (count($links) > 0) {
$output = '';
if (!empty($heading)) {
if (is_string($heading)) {
$heading = array(
'text' => $heading,
'level' => 'h2',
);
}
$output .= '<' . $heading['level'];
if (!empty($heading['class'])) {
$output .= drupal_attributes(array('class' => $heading['class']));
}
$output .= '>' . check_plain($heading['text']) . '</' . $heading['level'] . '>';
}
// adds clearfix class to <ul>
$attributes['class'][] = 'clearfix';
$output .= '<ul' . drupal_attributes($attributes) . '>';
$num_links = count($links);
$i = 1;
foreach ($links as $key => $link) {
$class = array($key);
if ($i == 1) {
$class[] = 'first';
}
if ($i == $num_links) {
$class[] = 'last';
}
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
&& (empty($link['language']) || $link['language']->language == $language_url->language)) {
$class[] = 'active';
}
// adds button class to each list item
$class[] = 'button';
$output .= '<li' . drupal_attributes(array('class' => $class)) . '>';
if (isset($link['href'])) {
$output .= l($link['title'], $link['href'], $link);
}
elseif (!empty($link['title'])) {
if (empty($link['html'])) {
$link['title'] = check_plain($link['title']);
}
$span_attributes = '';
if (isset($link['attributes'])) {
$span_attributes = drupal_attributes($link['attributes']);
}
$output .= '<span' . $span_attributes . '>' . $link['title'] . '</span>';
}
$i++;
$output .= "</li>\n";
}
$output .= '</ul>';
}
return $output;
}
At the moment this code affects every menu item on the page. I only want it to affect the menu item that appears within the 'node' part of the page.
How would I do this?
Thanks.
Comments
For a solution visit the
For a solution visit the following link: http://drupal.org/node/1170752