on the front page, if a primary link is set to then, when the front page is selected, the li that contains the link isn't set to be the 'active' class, though, the achor is.

Comments

George2’s picture

... when a primary link is set to [front]

George2’s picture

i've managed to fix this by changing the function theme_menu_links

PREVIOUS:

function theme_menu_links($links) {
  if (!count($links)) {
    return '';
  }
  $level_tmp = explode('-', key($links));
  $level = $level_tmp[0];
  $output = "<ul class=\"links-$level\">\n";
  foreach ($links as $index => $link) {
    $output .= '<li';
    if (stristr($index, 'active')) { 
      $output .= ' class="active"';
    }
    $output .= ">". l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment']) ."</li>\n";
  }
  $output .= '</ul>';

  return $output;
}

I changed one line:

NEW:

        if (stristr($index, 'active') || ($link['href'] == '<front>' && drupal_is_front_page()) ) {  // if the current page is the front page and the url is pointing to the front page, set as active
George2’s picture

Status: Active » Needs review
kulfi’s picture

Not sure where this belongs, but the 'active' class is set incorrectly in the following instance:

Primary menu items and links:

Home -- <front>
Content -- node
Register -- user/register
Login -- user

Clicking on Register and/or Login incorrectly sets the 'active' class (on both li and a HTML elements).

This is from core (i.e. persists if blank theme is used) and the above patch doesn't address it.

drumm’s picture

Status: Needs review » Active

Instructions for creating patches are at http://drupal.org/patch/create.

This should be fixed in whatever calls theme('menu_links') to add 'active' to the appropriate array index. I can't find anything that actually calls theme('menu_links').

bjorpe’s picture

I figured out that the primary links array is created in menu_primary_links (called by phptemplate_page).

However, it seems like this problem has been solved by #101904: Secondary links don't work for <front>

bjorpe’s picture

Status: Active » Closed (duplicate)