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

    I am using modx evo and would like to achieve the following using wayfinder. Please suggest.

    <ul>
    <li class="green">Green</li>
    <li class="yellow">Yellow</li>
    <li class="red">Red</li>
    </ul>

    Regards.
      • 26016
      • 561 Posts
      Hi,
      I’ve got a super easy way if you don’t mind putting the class on the link instead of the LI:

      Edit your Green document, and just put

      class="green" 


      ... in the Link Attribute. And you get this:

      <ul>
      <li><a href="something" class="green">Green</a></li>
      </ul>


      Otherwise you can use the Link Attribute as above, then you can template the <li> and change your Wayfinder call to use that template.

      Here’s the template chunk for your Row Template, I’ll name it MyMenuChunk. Notice how I added attributes to it.
      <li[+wf.id+][+wf.classes+] [+wf.attributes+]>
      	<a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a>
      	[+wf.wrapper+]
      </li>


      And your call will be something like this, calling the chunk:
      [[Wayfinder? &startId=`0` &level=`1` &rowTpl=`MyMenuChunk`]] 


      This is the Evo version. Slightly different syntax for Revo for chunk and call. You can work that out. smiley

      Cheers, Dave
        MODx and Wordpress development
        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        For the rowTpl chunk have something like this:
        <li[+wf.id+]class="[+wf.linktext+] [+wf.classnames+]"> 
        <a href="[+wf.link+]" title="[+wf.title+]" [+wf.attributes+]>[+wf.linktext+]</a> 
        </li>

        This will give each <li> a classname of the linktext (by default the menu title) as well as any classnames Wayfinder generates (such as last or active). You can use any of the wf. placeholders to generate the classname.
        [+wf.classes+] - where classes specifed will be inserted (includes class=" ")
        [+wf.classnames+] - outputs the just the class names (without class=" ")
        [+wf.link+] - the href value for your link
        [+wf.title+] - text for the link title
        [+wf.linktext+] - text for the link display
        [+wf.wrapper+] - where to insert a submenu
        [+wf.id+] - where to insert unique id
        [+wf.attributes+] - where to insert link attributes
        [+wf.docid+] - the document identifier for the current item
        [+wf.subitemcount+] - displays the number of items in a folder
        [+wf.description+] - output the description field
        [+wf.introtext+] - output the introtext field
          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
          • 26016
          • 561 Posts
          Yup, Susan’s way is great. Mine is a little more literal if you actually want "green", "blue", "namaste", whatever you’d like.

          Susan,
          Happy Birthday, Girlfriend!!!!
          Dave
            MODx and Wordpress development
            Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
            • 26163
            • 43 Posts
            Thanks everyone. I will definitely give it a try. But I encountered one problem. When I tried to add a resource, the "Link Attribute" somehow does not get displayed. It disappears immediately. When I inspected the element via firebug, I saw it there in the code but with tag display:none. Why is it not getting displayed on the page?
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              It’s only for the classname, it shouldn’t be getting displayed anyway. On the other hand, it’s odd that it should be getting that attribute. Post your rowTpl, please.
                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
                • 26163
                • 43 Posts
                This is what I was trying to say, the field "Link Attributes" is not showing. Firebug shows display:none;. How can I show it on the page?


                Regards,
                Santosh
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Check your chunk "mm_demo_rules". This is installed by default and has a number demo settings, including one to hide that field. Comment out or delete that line in the chunk.
                    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
                    • 26163
                    • 43 Posts
                    Thanks, actually I had deleted the chunk "mm_demo_rules" so when I restored it back by copying from my another modx evo site, it worked again.
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      I believe that if there is no chunk, MM reverts to a default configuration file in assets/plugins/managermanager.
                        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