Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 UTC on 18 March 2024, to get $100 off your ticket.
By izus on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
7.x
Introduced in version:
7.12
Issue links:
Description:
- The
$parameters
argument of menu_build_tree() has a new key:$conditions
.
$conditions
is an associative array of custom database select query condition key/value pairs.
What does this change for developpers?
Well, let's understand it by an example:
-
before the change, if you want to retrieve the menu link tree of "Add content" (including "Add content" itself) for Administration menu using menu_build_tree(), you would try something like:
$node_add = db_query("SELECT * FROM {menu_links} WHERE router_path = 'node/add' AND module = 'system'")->fetch(); $tree = menu_build_tree($node_add->menu_name, array( 'expanded' => array($node_add->plid, $node_add->mlid), 'min_depth' => $node_add->depth, ));
but this retrieves the entire Navigation menu! You don't really need this!
-
After the change, you can specify conditions to be used in the query defined in _menu_build_tree. You can then try write something like :
$node_add = db_query("SELECT * FROM {menu_links} WHERE router_path = 'node/add' AND module = 'system'")->fetch(); $tree = menu_build_tree($node_add->menu_name, array( 'conditions' => array('p1' => $node_add->mlid), 'min_depth' => $node_add->depth, ));
Impacts:
Module developers