💾 Archived View for chirale.org › 2008-09-26_188.gmi captured on 2024-07-08 at 23:21:41. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2024-05-12)
-=-=-=-=-=-=-
On [Tertiary links on Drupal](../2008/07/10/tertiary-links-on-drupal/ "Permanent Link to "Tertiary links on Drupal"") I described a simple approach to display the “tertiary” menu (childrens of secondary menus) on Drupal x. This is an useful but sometimes limiting approach, since the secondary menu disappears when tertiary menu is displayed.
This is an alternative workaround made using a customized menu_tree function:
template.php:
function custom_menu_tree_secondary($pid = 1) { $menu = menu_get_menu(); $output = ''; if (isset($menu['visible'][$pid]) && $menu['visible'][$pid]['children']) { foreach ($menu['visible'][$pid]['children'] as $mid) { $type = isset($menu['visible'][$mid]['type']) ? $menu['visible'][$mid]['type'] : NULL; $children = isset($menu['visible'][$mid]['children']) ? $menu['visible'][$mid]['children'] : NULL; # display only the children menu of the current menu if(menu_in_active_trail($mid)) { $output .= theme('menu_tree', $mid); } } } return $output; }
page.tpl.php (in place of standard $secondary block):
<div id="secondary"> <?php if ($secondary_links): ?> <?php echo tools_menu_tree_secondary(variable_get('menu_primary_menu', 0));?> <?php endif; ?> </div>
Tested on:
https://web.archive.org/web/20080926000000*/http://api.drupal.org/api/function/menu_tree/5