We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23575
    • 4 Posts
    Hi - relatively new to MODx, so be gentle...

    How can I change it’s output so the ’selfClass’ is added to the <a> element and not the <li>?

    e.g.
    <li><a class="active" href="...">Page Title Here</a></li>


    currently it outputs as
    <li class="active"><a href="...">Page Title Here</a></li>


    My WayFinder call is
    [!Wayfinder? &startId=`[[UltimateParent? &topLevel=`2`]]` &hideSubMenus=`1` &selfClass=`active_doc`!]


    Cheers,

    Phil



      • 3707
      • 241 Posts
      You need to add a custom template chunk for each row of your menu using the &rowTpl parameter. Change your Wayfinder call to:
      [!Wayfinder? &startId=`[[UltimateParent? &topLevel=`2`]]` &hideSubMenus=`1` &selfClass=`active_doc` &rowTpl=`customRow`!]

      Then create your chunk (customRow):
      <li><a [+wf.classes+] href="[+wf.link+]">[+wf.linktext+]</a></li>

      You may need to use a different template chunk than &rowTpl depending on the rest of your menu, you can find details of the Wayfinder parameters here.
        • 23575
        • 4 Posts
        Thanks - I’ll check it out.

        Phil
          • 23575
          • 4 Posts
          Thanks - worked a treat. The only bit I had to change was to add ’[+wf.wrapper+]’ into the chunk, to show submenus inside the <li> element.

          E.g.

          <li><a [+wf.classes+] href="[+wf.link+]">[+wf.linktext+]</a>[+wf.wrapper+]</li>


          Cheers, Phil
            • 24495
            • 407 Posts
            A bit of learning-by-doing is ok isn’t it? grin