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

    Long time reader, first time poster and all that!

    I'm having an issue with Wayfinder due to a client request that's a bit out of the ordinary. Basically, they want each menu item to be a different colour. Hardcoded, it'd be something like:

    <ul>
    <li><a href="#" class="purple">Page1</a></li>
    <li><a href="#" class="orange">Page2</a></li>
    <li><a href="#" class="green">Page3</a></li>
    <li><a href="#" class="blue">Page4</a></li>
    </ul>



    I was hoping that this would mean that I could amend the snippet to include something that looks for a TV for each page, which would be a drop-down that selects the name of a CSS class.

    Is this possible? I can't work it out myself or find anyone else that's wanted to do it.

    Thanks in advance if you're able to help.

    This question has been answered by sottwell. See the first response.

    • discuss.answer
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The only way I've ever been able to do this sort of thing is to use the &rowIdPrefix property, which adds the resource ID to the specified prefix giving something like

      <ul>
      <li><a href="#" id="color1">Page1</a></li>
      <li><a href="#" id="color2">Page2</a></li>
      <li><a href="#" id="color3">Page3</a></li>
      <li><a href="#" id="color4">Page4</a></li>
      </ul>


      Unfortunately Wayfinder does not work with TVs.
        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
        • 41417
        • 6 Posts
        I'll look into that, I may be able to work with the rowIdPrefix...

        Thanks for your response!
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Depending on the menu, you could also use getResources instead of Wayfinder. getResources doesn't do nested structures, so it would only work for a single-level menu. Although you could have the top-level menu created with getResources, and have a Wayfinder call in the getResource's tpl to generate the submenus individually.

            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
            • 41417
            • 6 Posts
            The menu is unfortunately not single-level. However, your suggestion before works a charm. I've got a 'default' style so if the client adds another page (which is unlikely), it'll be the default style. However, I've set up individual IDs in the CSS (m1, m2, m3 etc) and used the &rowIdPrefix in the Wayfinder call, which deals with the ones that are there now.

            ...and it works!

            So thanks for your help with this one!