Johanna Johanna - 3 months ago 20
PHP Question

Custom Mobile Menu in Drupal 7 can't access child links

My company took over the maintenance of a website and I am trying to determine how to properly get both the top-level (parent) links as well as the child links. The code that was being used is:

<div id="monav">
$mobile_menu = menu_navigation_links('menu-mobile-nav');
print theme('links__menu_mobile_nav', array('links' => $mobile_menu));


This only spits out the top-level. I have been digging through forums and code trying to find the correct way to get the child links. Can you point me in the right direction oh wise Drupal gurus?

Note: setting the parent link to "Show as expanded" does not work.



The above code was spitting out an error so instead I am doing this.

template.php in the theme_preprocess_page(&$vars) function

//Render main menu 
$main_menu_tree = menu_tree(variable_get('menu_main_links_source', 'main-menu'));
$vars['main_menu'] =  $main_menu_tree;

Then I am displaying the menu in page.tpl.php using

  <div id="monav">
        print render($main_menu);

To make this menu mobile I added the following jquery

(function ($) {

//Mobile Navigation
$('#nav-toggle').click(function(e) {
$('#monav li.expanded > a').attr("href", "#");
 $("#monav li.expanded").click(function() {




Note I had to hide this in my css

#monav li.expanded .menu{