Programmatically render menu on search view I'm trying to programmatically build a menu on my site, it works fine on all pages except a search view. This code I'm using is below:

        $config = array('menu_name' =&gt; $menu_name, 'level' =&gt; 2, 'depth' =&gt; 10, 'expanded' =&gt; true);
        $menu_tree = menu_tree_build($config);


When I do a var_dump() of $menu_tree it has a content key in the array which has all the menu items, but only if the page is a 'normal' node. If it's the search results view then that array key is empty.

Does anyone have any idea why this is?

I also have two custom functions to change the output of the menu however these don't seem to be called as if I do a var_dump("test") at the start of them it has no affect. The two custom methods are:

THEME_menu_tree__menu_footer_links_1()
THEME_menu_link__menu_footer_links_1()
I worked it out, turns out the problem is different to what I thought.

Because the search view isn't in the menu structure I need to add different values to the $config array. Firstly I needed to add "parent_mid" so it knew what menu item to use as the root for the menu tree &amp; I needed to change the level to 1 to output the links I wanted. Although 2 was still outputting links, just the wrong ones for what I needed.

If you need to work out what the parent_mid is go to Admin > Structure > Menus > Your Menu &amp; hover over the edit link for the menu item you want to be the root of the menu tree, the ID is in the URL. You can also get it programatically, like I did, using menu_node_get_links().