We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5532
    • 251 Posts
    Hi There,

    I’m trying to create a news summary list that will also behave like a menu. i.e. if you click on a news item, an active class will be applied to the menu item.

    Because of this, I decided to use Wayfinder and try the &sortBy &sortOrder &limit parameters to sort the items by latest page id and limit the items to 5. The &sortBy &sortOrder parameters work great but the &limit parameter causes the menu to disappear.

    Here’s the Wayfinder call:
    [!Wayfinder? &startId=`[[UltimateParent]]` &outerClass=`subNavigation` &level=`1` &displayStart=`1` &startItemTpl=`subNavigationTitle` &sortBy=`id` &sortOrder=`DESC` &limit=`3`!]


    And here’s the template referenced in the above call:
    <a href="[~[[UltimateParent]]~]"><h3>[+wf.linktext+]</h3></a>
    [+wf.wrapper+]


    I think maybe Ditto would be better for this but before recommending using it, how would you get the list of links to behave like a menu with an active class?

    Any help would be much apprecited.
      • 26016
      • 561 Posts
      Hi,
      Though I’ve seen and solved myriad menu display problems, this is a new twist.

      I have not used the &limit parameter much. AFAIK, this parm will affect your whole menu, not just one level, and I would guess that this is why parts of your menu vanish when using it; maybe a level above the last one has more than the limit, and is being chopped off.

      Using Ditto for this... hmmmm... sounds tough. Of course, Ditto easily allows you to control how many docs are displayed, but I have not seen a way to "class" the current item. (if someone knows, great!) If I had to do this with Ditto output, I would probably consider using JQuery, which is a fair bit of work, probably overkill, and way off-topic.

      This isn’t as precise, but I wonder if instead you might want to make use of the "Publish Date" and "Un-Publish Date" to handle which ones are showing. Or if your client is in there editing often, maybe they’d be willing to do manually use Publish and Unpublish, or maybe Deleting old docs. Then Wayfinder can handle "active" items.

      Good luck, Dave
        MODx and Wordpress development
        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
        • 5532
        • 251 Posts
        Hey thanks for the reply.

        After fiddling about, the following Wayfinder call worked great:
        [!Wayfinder? &startId=`58` &outerClass=`subNavigation` &level=`1` &displayStart=`1` &limit=`6` &startItemTpl=`newsHeadlinesTitle` &sortBy=`createdon` &sortOrder=`DESC`!]


        Which references the following template:
        <a href="/2010-news"><h3>News Headlines</h3></a>
        [+wf.wrapper+]


        Not sure what I was doing wrong before but the above worked for me...

        Cheers