We recently (better late then never) introduced menu_build_tree(). The menu block module could probably use this to build its menu trees. If for some reasons it cannot, menu_build_tree() can serve as a reference implementation of how to query, cache and build a menu tree, which definitely not easy to get right :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JohnAlbin’s picture

Yep, this is on my radar. :-)

richsky’s picture

Issue tags: +menu_block

Well, I'm wondering if it could allow me to use a unique id on the <ul> of my choice...

since

<?php
function [theme]_menu_tree__menu_block($tree) { //-----> All the ul have id="nav" really bad :(
 	return '<ul id="nav">'. $tree .'</ul>';
}
?>
JohnAlbin’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev
Priority: Normal » Critical

Unfortunately, there's a convoluted dependency for implementing this.

The recent Menu position modules uses a tricky pre-cache strategy of building and caching the menu tree before core or Menu block module requests it. Its completely hacky, but works in both D7 and D6.

If we implemented menu_build_tree in the 7.x-2.x branch of Menu block, menu position module would no longer work since it only works with root-level trees and not sub-trees.

The patch at #520106: Allow setting the active menu trail for dynamically-generated menu paths. would allow Menu position to dump its pre-cache strategy and start using those new APIs. Which would free up Menu block to use the menu_build_tree() functions. Since the patch isn't in Drupal 7.0, I'll have to roll a Menu block 7.x-2.0 without it. Moving to the 7.x-3.x branch.

Marking this as critical, since its blocking my plans to prepare parts of Menu block for Drupal 8.

JohnAlbin’s picture

Status: Active » Postponed
JohnAlbin’s picture

Title: Use menu_build_tree()? » Use menu_build_tree()
Status: Postponed » Active

This is unblocked now that Drupal 7 has finally fixed #520106: Allow setting the active menu trail for dynamically-generated menu paths..

eärendil’s picture

Priority: Critical » Normal
Status: Active » Needs review
Issue tags: -menu_block +using menu_build_tree
FileSize
2.35 KB

Here is a possible use of the menu_build_tree function in the module to help build the tree. I have attached a patch for review, but be careful as the code is still in development.

JohnAlbin’s picture

Category: task » feature
FileSize
1.64 KB