My menu:
- Go to Frontpage
- Pick category
- Category 1
- Category 2
- Category 3
- Contact

I want my active menu item to be set as either "Category 1", "Category 2" or "Category 3", depending on some data set on the node with CCK($node->field_category). It seems to be a simple task, but I cannot find the correct solutions :-(

menu_set_active_item('pickcategory/category1') overrules the node module menu callback: node/*
menu_set_location(array(array('title', 'path', 'type')) gives me an fatal error

I don't use taxonomy and cannot use it for this project!

Comments

andershal’s picture

Category 1, 2, 3 are submenus to "Pick category"...

--
Anders Hal

--
Anders Hal Werner

nielsz’s picture

I'm having the same problem. It should be easy, but cannot get this to work in Drupal 6. Any solutions?

alienzed’s picture

If you're clever, you'll be able to use
THEME_links(($links, $attributes = array('class' => 'links')){
global $language;
$output = '';

// Make our item active
if (//put your logic here)
{
$org = $_GET['q'];
menu_set_active_item('topic/all/keynote'); // nid is taken from primary links
}

if (count($links) > 0) {
$output = '

    ';

    $num_links = count($links);
    $i = 1;

    foreach ($links as $key => $link) {
    $class = $key;

    // Add first, last and active classes to the list of links to help out themers.
    if ($i == 1) {
    $class .= ' first';
    }
    if ($i == $num_links) {
    $class .= ' last';
    }
    if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '' && drupal_is_front_page()))
    && (empty($link['language']) || $link['language']->language == $language->language)) {
    $class .= ' active';
    }
    $output .= '

  • $class)) .'>';

    if (isset($link['href'])) {
    // Pass in $link as $options, they share the same keys.
    $output .= l($link['title'], $link['href'], $link);
    }
    else if (!empty($link['title'])) {
    // Some links are actually not links, but we wrap these in for adding title and class attributes
    if (empty($link['html'])) {
    $link['title'] = check_plain($link['title']);
    }
    $span_attributes = '';
    if (isset($link['attributes'])) {
    $span_attributes = drupal_attributes($link['attributes']);
    }
    $output .= ''. $link['title'] .'';
    }

    $i++;
    $output .= "

  • \n";
    }

    $output .= '

';
}

return $output;

// set original value
menu_set_active_item($org);
return $output;
}