We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9207 ☆ A M B ☆
    • 2,475 Posts
    This situation often comes up when building navigation menus and designers want a special class to be added to the current page. Some Snippets offer a specialized tpl dedicated to formatting the current resource, but at best this can result in "chunk clutter"; a well crafted output filter would help alleviate this.

    Wanted: a "current" class for the current page:

    <li class="tab current"><a href="http://somepath.com/page">Page 1</a></li>


    So our tpl used to format Snippet output might look like this:

    <li class="tab [[+id:equals=`[[*id]]`:default=`current`]]"><a href="[[~[[+id]]]]">[[+menutitle]]</a></li>


    Is something like that already possible?

    The workaround is writing a quick Snippet with inputs for the id from the other Snippet and the current id.

    Thanks!
      • 3749
      • 24,544 Posts
      I think you want something like this:
      <li class="[[+id:is`[[*id]]`:then=`something`:else=`something else`]]"><a href="[[~[[+id]]]]">[[+menutitle]]</a></li>


      I think Wayfinder has this built in, though. I believe it assigns the class "active" to the current page by default.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 9207 ☆ A M B ☆
        • 2,475 Posts
        Thanks again, Bob. Ah... the little-known "is-then" construct. This might be easier to google if it were "if-then".

        WayFinder wasn’t viable here (at least I couldn’t see how to do it with WayFinder) because I needed the contents of a folder AND a list of page IDs to always include. getResources did that much more easily.
          • 3749
          • 24,544 Posts
          Quote from: Everett at Apr 15, 2011, 08:00 AM

          Thanks again, Bob. Ah... the little-known "is-then" construct. This might be easier to google if it were "if-then".

          Take your pick:

          Output Modifer
          -------------

          is

          (aliases: equals, eq, equalto, isequal, isequalto).

          I think "if" might work too, but I haven’t tried it.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting