I have been developing a new site over the last week and thought I would share my solution to a little MODx navigation issue that has cropped up on occasion. I often fined myself frustrated when trying to explain/discern navigational issues in the forums. So, rather than diving into a lengthy explanation of 1st tier, 2nd tier and 3rd tier navigation I thought the screenshot below would help condense my explanation.

MODx Navigation ExampleIn the past I have run into issues when building navigation like this because the secondary navigation completely changes depending on which area of the 1st tier you are in as you view the site.

Best that I can gather (Please let me know if I am wrong here), Wayfinder will not output only the active Parent directory name and link (red circle) with a single call. The rest of the menu can be generated, but not this line.

My solution was to use the Wayfinder, UltimateParent and GetField snippets to create a single, unordered list:

<ul> <li><a href="[~[[GetField? &docid=`[[UltimateParent]]` &field=`id`]]~]" title="[!GetField? &docid=`[[UltimateParent]]` &field=`menutitle`!]">[!GetField? &docid=`[[UltimateParent]]` &field=`menutitle`!]</a> [!Wayfinder? &startId=`[[UltimateParent]]` &excludeDocs=`1` &hideSubMenus=`1`!] </li> </ul>

As I stated above, there may be a more elegant solution to this issue and I would love to hear it if there is. But one of the MODx strengths I believe this issue illustrates is just how flexible the this framework is to work with. With MODx there can easily be multiple solutions any issue.

Addendum 11/06/09 — Check out the comments on this post for the “more elegant solution” that I had been hoping for.


View Comments on “A MODx Navigation Issue”

You can track this conversation through its atom feed.

  1. NICCAI says:

    Sorry, you want to show the children and just their parent? Am I understanding that right?

  2. Gregory Smart says:

    Yes, for instance this site has 4 primary containers in which the site resides. If I am in any container I want to see the active Parent and all it's children.

  3. NICCAI says:

    Add to your wayfinder call &displayStart=`TRUE`
    &startItemTpl=`yourtemplatename`

    I think that will do what you want.

    As an aside, the ebook “The (almost) Complete Guide to Creating Menus in
    MODx using Wayfinder” is awesome.

    [PDF]
    http://modxcms.com/forums/index.php?action=dlat...

  4. Gregory Smart says:

    That works like a charm too. Definitely a preferable approach. Thank you NICCAI.

  5. NICCAI says:

    Sorry, you want to show the children and just their parent? Am I understanding that right?

  6. Gregory Smart says:

    Yes, for instance this site has 4 primary containers in which the site resides. If I am in any container I want to see the active Parent and all it's children.

  7. NICCAI says:

    Add to your wayfinder call &displayStart=`TRUE`
    &startItemTpl=`yourtemplatename`

    I think that will do what you want.

    As an aside, the ebook “The (almost) Complete Guide to Creating Menus in
    MODx using Wayfinder” is awesome.

    [PDF]
    http://modxcms.com/forums/index.php?action=dlat...

  8. Gregory Smart says:

    That works like a charm too. Definitely a preferable approach. Thank you NICCAI.

Leave a Reply

You must be logged in to post a comment.

blog comments powered by Disqus