I have a sort of a procedural question...
Say I have a page structure with two different menu systems: one on the top and one on the sidebar. The sidebar menu is where all the dynamically created pages will go. Wayfinder is the obvious choice to make that happen in MODx. My question is with the top menu. Say hypothetically this menu will be a short list of fixed links like Home, About, Contact etc. Say this menu list will never change and is displayed with a one graphic nav_sprite that is rendered with CSS and possibly jQuerry. The sprite displays direct links with no drop down sub links.
Is Wayfinder really needed for this menu? The code for this menu could just be rendered within the template and/or chunk, no? Or is it better practice to code this kind of menu with Wayfinder?
Just trying to get a handle on how folks address this kind of two menu structure...
Thanks,
Max
I wouldn’t use Wayfinder for the top menu unless you want some kind of ’active’ class on the current item, which is what I tend to have, for highlighting.
I use Wayfinder for the top/primary navigation as well, but will use the includeDocs parameter to only include the pages I need. Rarely changes, and since my primary nav is usually image based, adding new items would need some manual intervention anyway.
The only thing I don’t like about this approach is that I have to modify my CSS file to use the Wayfinder-given IDs instead of my semantic ones. "primary-nav-1" just isn’t as clean as "primary-nav-products" IMHO.
I think I’d skip the overhead of a Wayfinder call. Wayfinder does a quite a lot of processing that you don’t need at all, and does it for every page (although the results could be cached in your scenario). I might put the top menu in a chunk.
Thanks guys...
Some good viewpoints here...
-
MODX Staff
- 12,272 Posts
If you cache the Wayfinder call the heavy processing only happens once.
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
In some cases I will use a custom menu builder snippet for the main navigation. You can get the classes to work with a little simple logic to check the current page id and test against the id for the menu pages.
I build a menu based on a comma delimited list of ids &docs=`2,4,15,1,33` then turn the string into an array and process each item with a foreach loop and use the API to get the document fields you want to output.