Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to *optionally* override a theme in Drupal 6?
    text
    copied!<p>I want to override the theming of only one (custom) menu. I can do this with phptemplate_menu_tree() but - of course - it overrides the rendering of all menus.</p> <p>I've tried returning FALSE (an obvious technique IMO) if the menu is not the specific one I want to override - but this doesn't cause the overridden theme function to be called.</p> <p>My only alternative (when the menu is anything other than the specific one) is to call the overridden function from within phptemplate_menu_tree() - but this seems to defeat the whole point of the override system, since the default rendering function will be hard-coded therein. </p> <p>I hope the explanation is clear, and any help is greatly appreciated - tks.</p> <h1>UPDATE</h1> <p>For the sake of future reference, I'll explain how I solved this.</p> <p>First off, the menu rendering starts with this function in menu.module: <code><pre> function menu_block($op = 'list', $delta = 0) { $menus = menu_get_menus(); // The Navigation menu is handled by the user module. unset($menus['navigation']); if ($op == 'list') { $blocks = array(); foreach ($menus as $name => $title) { // Default "Navigation" block is handled by user.module. $blocks[$name]['info'] = check_plain($title); // Menu blocks can't be cached because each menu item can have // a custom access callback. menu.inc manages its own caching. $blocks[$name]['cache'] = BLOCK_NO_CACHE; } return $blocks; } else if ($op == 'view') { $data['subject'] = check_plain($menus[$delta]); $data['content'] = menu_tree($delta); return $data; } } </code></pre></p> <p>If you only want to override how individual item (links) are rendered then you can use the theme system (there are loads of references on how do this) - but if you want complete control on how the <em>entire</em> menu tree is rendered (for example, wrapping the output in nested DIVs so it can be centred on the page) then there is no way to override menu_block().</p> <p>Therefore, I removed the menu I wanted to render differently from the administer blocks page (site building->blocks) and rendered the menu directly in my page.tpl.php using code something like this: (angle brackets removed) <code><pre> $m = menu_tree_page_data('my-menu-id'); $o = "DIV"; foreach($m as $k => $v){ $o .= "SPAN {$v['link']['title']} /SPAN"; } $o .= "/DIV"; echo $o; </code></pre></p> <p>I hope this helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload