We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16436
    • 7 Posts
    Hi, i do not get it, how to tell the wayfinder that every menu link has its own class? The thing is every menu item has defined its own place in page, it is not ordered menu list.
    for example i have html like this:
    <ul>
    <li class="home"><a href="#">Home</a></li>
    <li class="about_us"><a href="#">About Us</a></li>
    <li class="contacts"><a href="#">Contacts</a></li>
    </ul>
    


    Thanks!
      • 26016
      • 561 Posts
      Hi,
      I have a way of doing this, it’s not automatic, though. You edit the "link attribute" on a page. This will affect the actual link, not the list item.

      Try adding something like the following to the Link Attribute on your About Us page:

      class="about-us"

      And take a look at the result. You could also use "id" instead of "class". I have used this method for cases when the client wanted a unique image to appear as background for each menu item, for instance.

      Cheers, Dave
        MODx and Wordpress development
        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
        • 16436
        • 7 Posts
        ok, i still can not figure it out,

        for example html and css code below, how to add wayfinder to it?

        html:
        <div id="menu">
        <ul>
        <li class="home"><a href="#">Home</a></li>
        <li class="about_us"><a href="#">About Us</a></li>
        <li class="contacts"><a href="#">Contacts</a></li>
        </ul>
        </div>
        


        css:
        .home {
        margin-top: 50px;
        }
        
        .home A:active{
        background: (image.gif);
        }
        
        .about_us {
        margin-bottom:10px;
        }
        
        .about_us A:active{
        background: (image.gif);
        }
        


        i suppose i should use different &rowTpl chunks, but i can not understand - how?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          You would need to use a bit of trickery there. Since Wayfinder applies the exact same HTML to each line, you can’t do that. However, each document has a "link attributes" field. This field was originally intended to have things like target="_blank", and Wayfinder will add the contents of that field verbatim where the [+wf.attributes+] placeholder is put. So in your rowTpl you could have
          <li[+wf.attributes+]><a ....

          Then for each document in its link attributes field, put class="home", or class="about_us". Just make sure that the rowTpl doesn’t have the [+wf.attributes+] placeholder inside the <a> tag, as it would if this were really link attributes.
            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
            • 16436
            • 7 Posts
            ok, thank you very much, now i get it smiley

            just one strange thing with links active state. My rowTpl looks like this:
            <li [+wf.attributes+]><a [+wf.classes+] href=...


            and the css code looks like:
            .active {
            color: #ffffff;
            background: url(image.gif);
            }
            

            the thing is that the background image for active state defined in css is displayed but the color defined in css is not displayed. Actually the color is displayed from defined visited state.

            Background image disapears if i turn off background string in Firebug.
            How could that be?
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Since you are using the [+wf.attributes+] tag to hijack the [+wf.classes+] tag for the li tag, which is usually used to wrap the <a> tag, you may need to add another block-level element for wrapping the <a> tag and carry the css for the active links. Perhaps a set of <span> tags set to display: block, then otherwise treated as normally is done for the <li> element.
                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