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

    I'm trying to match between both of these getParentId & [[+id]] on my chunk.
    I have output of echo only just [[getParentId]] & [[+id]] , but not sure why when I apply if/else condition inside.
    my chunk doesn't have any output message already.

    Method 1:
    [[If?
           &subject=`[[getParentId]]`
           &operator=`EQ`
           &operand=`[[+id]]`
           &then=`Its active`
           &else=`Its not active`
        ]]


    Method 2:
    [[[[getParentId]]:is=[[+id]]:then=`its active`:else=`its not active`]]


    I'd try both method but seems like the code not working...may I know what did i do wrong?

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

    • discuss.answer
      • 30585
      • 833 Posts
      What do you get when you replace your chunk with [[getParentId]]? If you get nothing, try calling it uncached: [[!getParentId]].

      If the uncached call returns a value, then this should work:
      [[!If?
         &subject=`[[!getParentId]]`
         &operator=`eq`
         &operand=`[[+id]]`
         &then=`It's active`
         &else=`It's not active`
      ]]
      

      Your second call isn't valid. Try this:
      [[getParentId:is=`[[+id]]`:then=`its active`:else=`its not active`]]
      // Call it uncached if need be
      

      The mosquito trick won't do it here since there are no element tags in your conditionals. The syntax is also wrong. Typically it works like this:
      [[[[getParenId:is=`[[+id]]`:then=`myElement?...`:else=`myOtherElement? ...`]]]]
      [ed. note: treigh last edited this post 8 years, 3 months ago.]
        A MODx Fanatic
        • 3749
        • 24,544 Posts
        Can you explain exactly what you're trying to do?

        It looks like you're comparing the ID of the resource being retrieved with the ID of its parent. Those will never match, since a resource is never going to be its own parent. Maybe I'm missing something.
          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
          • 51474
          • 27 Posts
          Quote from: BobRay at Dec 29, 2015, 10:03 PM
          Can you explain exactly what you're trying to do?

          It looks like you're comparing the ID of the resource being retrieved with the ID of its parent. Those will never match, since a resource is never going to be its own parent. Maybe I'm missing something.
          I'm actually want to match the resource id, if matched , then will output a 'active' class and applied on the li tag.