We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9995
    • 1,613 Posts
    I have a button, when its parent or parentparent of id 50 I need to add class="active"
    [*parent:is=`50`:then=`class="active"`:else=``*] doesn't cover the subpages.

    Any idea how I can do this?

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

      Evolution user, I like the back-end speed and simplicity smiley
      • 13226
      • 953 Posts
      Have you tried using ultimateparent = 50 ?
        • 9995
        • 1,613 Posts
        Hmm, then I need to do something like this.
        Not very clean solution but it works.

        [*parent:is=`50`:then=`class="active"`:else=``*][*ultimateparent:is=`50`:then=`class="active"`:else=``*]


          Evolution user, I like the back-end speed and simplicity smiley
        • discuss.answer
          • 13226
          • 953 Posts
          Let me know if I am wrong BUT:

          Everything that is underneath "50" using ultimateparent will have the active class, not just parentparent

          Using "IF" it looks like this:

          [[if? &is=`[[UltimateParent]]:in:50` &then=`class="active"` &else=``]]


          The above code is a modified call that comes from one of my templates, it does basicaly the same as what you want, it adds to all documents "nested or not" underneath ID 50

          I think if that doesn't work exactly how you want it, you could do something like the following, a kind of catch-all:

          [[if? &is=`[*parent*]:is:50:or:[[UltimateParent]]:in:50` &then=`class="active"` &else=``]]


          I haven't tested this smiley [ed. note: iusemodx last edited this post 7 years, 11 months ago.]
            • 9995
            • 1,613 Posts
            Thanks, it works!
              Evolution user, I like the back-end speed and simplicity smiley