Responsive Multi-level Navigation
-
Kind of hard to describe but…
I’m building a site that has a two-level navigation structure. The first level is a ‘section’, the submenus are ‘topics’ within that ‘section’. To clarify, the ‘section’ items in the navigation don’t have any content, they are simply a ‘section’ that groups related content together. Clear as mud?
So here’s the thing — in desktop mode everything works fine, click on a ‘section’ and the subnav with related ‘topics’ opens out. Cool.
Mobile, however, is a different story. Initial view shows the ‘Menu’ button, click on that and EVERYTHING falls out — a big long list of ‘sections’ with all their related ‘topics’ displayed. The result is a big, long navigation list that requires endless scrolling before you actually get to see the page…
So how do I get the ‘sections’ to act like buttons in mobile view, that you click to open the section and see related ‘topics’?
Before you ask, yes, I’ve tried various plugins but these compromise the design and UX of the site. Not happy with the end result.
I did find this page: https://awhitepixel.com/wordpress-menu-walkers-tutorial/
I think that the answer is here somewhere, and I will be able to make the ‘event listener’ on parent element of ‘submenu’ act like the ‘event listener’ on ‘site navigation’ that produces the ‘Menu’ button? I have ‘menu walker’ loaded but not enabled. I’m not sure how to instruct it. I currently have the following loaded:
class AWP_Menu_Walker extends Walker_Nav_Menu { function start_el(&$output, $item, $depth=0, $args=[], $id=0) { $output .= "<li class='" . implode(" ", $item->classes) . "'>"; if ($item->url && $item->url != '#') { $output .= '<a href="' . $item->url . '">'; } else { $output .= '<span>'; } $output .= $item->title; if ($item->url && $item->url != '#') { $output .= '</a>'; } else { $output .= '</span>'; } if ($args->walker->has_children) { $output .= '<i class="caret fa fa-angle-down"></i>'; } } };
This does nothing at all — doesn’t even produce the promised ‘caret’ much less give me a button to work with…
Can anybody shed a bit of light here??
- The topic ‘Responsive Multi-level Navigation’ is closed to new replies.