1

this is a bit of a backwards question, in that "not being applied as expected" means "I expected it to break, and it didn't". However, I'd like to know WHY I'm seeing the behaviour that I do.

I'm generating a path-specific site submenu, as detailed in this question. Briefly, I'm rendering the main menu exactly how it is in the default page.tpl.php:

<?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => array('links', 'inline', 'clearfix')))); ?>

... but the submenu is custom-built (see function in linked question) and rendered via:

print drupal_render($page_submenu);

I need to adjust the HTML output for my submenu, and have added the following to my theme's template.php:

function mytheme_menu_tree($variables){
  return '<ul class="your-custom-class" id="your-custom-id">' . $variables['tree'] . '</ul>';
}
function mytheme_menu_link($variables) {
  $element = $variables['element'];
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . "</li>\n";
}

This does have the required effect on my submenu HTML output. However, it doesn't adjust anything in the main menu HTML output. Even though I don't want it to, I'd like to know why those two functions haven't affected it, because I was kinda expecting them to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.