We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45408
    • 5 Posts
    I want to add a class ("navbar-right") in last Li. But wayfinder is adding the class in wrong place(in this case in "a" element)

    Below is the output:

    <ul class="nav navbar-nav">
    <li class="dropdown"><a class="active" href="/about-us.html" title="About Us">About Us</a></li>
    <li class="dropdown"><a href="/software-services.html" title="Services">Services</a></li>
    <li class="dropdown"><a href="/products.html" title="Products">Products</a></li>
    <li class="dropdown"><a href="/knowledge-center.html" title="Knowledge Center">Knowledge Center </a></li>
    <li class="dropdown"><a class="navbar-right" href="/events1.html" title="Events">Events</a></li></ul>


    This is how i'm calling wayfinder:


    [[Wayfinder? &startId=`0` &parentRowTpl=`Firstlevel-NavItem` &outerTpl=`Outer-Nav` &innerTpl=`Firstlevel-Nav` &rowTpl=`Inner-Row` &excludeDocs=`1,136` &lastClass=`navbar-right` ]]


    Above navigation is 2 level drop down and I want to add class in only first level's last element.

    Thanks in advance! help needed urgently.
    • Then you need to look at your rowTpl. The rest of the rows will be handled by the innerRowTpl. Or, you can add a level to them all and work with level1.last
        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
        • 45408
        • 5 Posts
        Quote from: sottwell at Oct 17, 2013, 06:53 AM
        Then you need to look at your rowTpl. The rest of the rows will be handled by the innerRowTpl. Or, you can add a level to them all and work with level1.last


        I seriously don't get you. But here is the code i'm using for rowTPL

        <!--First level list item-->
        <li class="dropdown" ><a [+wf.classes+] href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a>
        [+wf.wrapper+]
        </li>


        Can by any means i can add class to last li?
        • You need to have the [[+wf.classes]] placeholder in the li tag. Wayfinder automatically adds a "last" class to reach set of rows.

          Since you want to have the 'dropdown' class in the li tags, you'll need to use this instead:
          <li class="dropdown [[+wf.classnames]]"><a ...
            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
            • 30912
            • 463 Posts
            Quote from: sottwell at Oct 17, 2013, 08:52 AM
            You need to have the [[+wf.classes]] placeholder in the li tag. Wayfinder automatically adds a "last" class to reach set of rows.

            Since you want to have the 'dropdown' class in the li tags, you'll need to use this instead:
            <li class="dropdown [[+wf.classnames]]"></li>

            Hi Susan,

            Shouldn't that be

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


            as theyre on the Evo codebase smiley (no disrespect intended)


            • As far as I know, Evo or Revo, wf.classes will put the whole attribute - class="classname", which you don't want, since you are already specifying class="dropdown". The wf.classnames will just add the classnames, not the whole attribute.
                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
                • 6629
                • 60 Posts
                Do you really need a class? You could target the link with :last-child.
                .navbar-nav li:last-child a { color: #f00 }
                  • 30912
                  • 463 Posts
                  @Sottwell, at least the syntax was changed, wasnt aware of the classnames attribute though thank you.