Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I have a pretty complicated multi site setup and would like to programmatically embed menus into page.tpl.php. The following works to get the top level menu.
$block = module_invoke('menu', 'block', 'view', 'primary-links');
print $block['content'];
I would like to pass starting level, depth, etc to the module. Is it possible to pass extra arguments?
Comments
Comment #1
bstoppel CreditAttribution: bstoppel commentedI found another way to do this by using menu_tree_build.
The following code gets that second level and deeper menu items and displays them.
Not sure if this is the right way to go about what I am wanting to accomplish, but it works for me.
Comment #2
bensnyder CreditAttribution: bensnyder commentedthank you for posting this
Comment #3
Dave ReidIf it works, looks like a fine solution. Thanks for posting.
Comment #5
webdrips CreditAttribution: webdrips commentedHi all.
I have in interesting problem: I have a menu block that works beautifully out of box. However, I have a series of page displays in a view, and I was trying the above code in my views template file (before I noticed this post), and the
$tree['content']
is an empty string, but$tree['subject']
contains the correct menu title.(My code is almost identical to the above post, so I did not bother).
Can anyone give me kick in the right direction?
Thanks,
Dan
Comment #6
webdrips CreditAttribution: webdrips commentedSeems like my real problem is the $tree[key]['link']['in_active_trail'] will always be FALSE when a view is being used to render a page.
Anybody have any experience overcoming this issue?
Thanks,
Dan
Comment #7
webdrips CreditAttribution: webdrips commentedOK I figured it out for anyone interested.
This snippet works on a page generated by the Views module:
Place the above code in your view's template file and it should work.