We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19309
    • 49 Posts
    Since I’m a beginner with MODx, please forgive me if this is a dull question. I just could not find an already existing threat here related to my question, od a sulution in the documentation.

    I want to build a dropdown menu with two sub-levels, using the suckerfish method (http://www.htmldog.com/articles/suckerfish/dropdowns/). So nearly everything is done via CSS (and a little piece of JavaScript especially for beloved IE 6). The only thing needed as HTML output is just an unordered list. Of course this can be done easily with Wayfinder.

    But here’s my question: I want to highlight the top-level parent menu item of the active page, so that the horizontal menu bar indicates, which part of the site you are looking at right now – even if the active page itself is located somewhere on level two or three in the navigation tree and thus hidden in the closed dropdown menus.

    Since there is no way of doing something like a reverse cascading in CSS (or did I miss something?), I need an extra class added to the corresponding top-level parent item of the active page in the HTML output.

    This is an example what it should look like:

    <ul id="navigation">
    <li><a href="…" title="…">Lorem</a></li>
    <li><a href="…" title="…" class="toplevelactive">Ipsum</a> <!-- corresponding top-level parent menu item: class="toplevelactive" -->
    <ul>
    <li><a href="…" title="…">Lorem</a></li>
    <li><a href="…" title="…">Ipsum dolor sit amet</a>
    <ul>
    <li><a href="…" title="…">Lorem</a></li>
    <li><a href="…" title="…" class="active">Ipsum</a></li> <!-- active page: class="active" -->
    <li class="last"><a href="…" title="…" >Dolor</a></li>
    </ul>
    </li>
    <li class="last"><a href="…" title="…">Dolor</a></li>
    </ul>
    </li>
    <li><a href="…" title="…">Dolor</a></li>
    </ul>

    Unfortunately I’m still a PHP beginner, so if there is any more or less ready-to-use solution using Wayfinder and UltimateParent, that would be great. Otherwise I’ll have to dig into PHP a little faster than planned wink

    Thanks a lot for any suggestions.


    Oops, just saw in Kongondo’s ebook, that &hereClass is not only applied to the current page, but also to each parent item up the document tree. So my question is unnecessary.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      For a nice "cheat-sheet" one-page list of the parameters and what they do, download the zip file at the beginning of this page. I can’t live without it!

      http://wiki.modxcms.com/index.php/Wayfinder200
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 19309
        • 49 Posts
        Great, thanks a lot for the link. smiley