We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36926
    • 701 Posts
    Hi, I’m trying to use the following phx call but not having a lot of luck
    
    [+phx:if=`[!UltimateParent!]`:is=`2`:then=`text1`:else=`text2`+]
    


    Anyone any ideas why this isn’t working. Phx is working fine and so is ultimateparent. I can get the above call to work fine with [*parent*] but can’t use parent as i’ve got more than 1 level deep.
      • 36926
      • 701 Posts
      Quote from: bennyb at Sep 20, 2010, 09:24 PM

      Hi, I’m trying to use the following phx call but not having a lot of luck
      
      [+phx:if=`[!UltimateParent!]`:is=`2`:then=`text1`:else=`text2`+]
      


      Anyone any ideas why this isn’t working. Phx is working fine and so is ultimateparent. I can get the above call to work fine with [*parent*] but can’t use parent as i’ve got more than 1 level deep.

      Anyone any ideas, can’t work out why this isn’t work. The use of UltimateParent is actually used in the PHx docs, but can’t get that example working either.

      I’m trying to do this on evo 1.0.4
        • 4229
        • 16 Posts
        Just to add that I’m also trying to use PHx with UltimateParent without success.

        Were you able to solve this yourself?

        I’ve tried it two different ways:
        [+phx:if=`[!UltimateParent!]`:is=`2`:then=`current`:else=``+]

        The above is essentially the example given in the Wiki, which should surely work?
        I also tried it as follows:
        [!UltimateParent:is=`2`:then=`current`:else=``!]


        Putting [!UltimateParent!] yields an output of "2" elsewhere on the page, so that is working.

        I confirmed PHx to be working using:
        [*alias:is=`6th-grade`:then=`current`:else=``*]


        As the OP, I’m running Evo 1.0.4 and the latest version of PHx (2.1.4-GA, as referenced in the Wiki).

          • 5340
          • 1,624 Posts
          Maybe this can answer your question
          When MODx serves up a page, it is pulling together multiple components and executing multiple scripts to assemble the page into the final product that is displayed to the user. A MODx page can be composed of six different types of tags which are processed in the following order:

          1. [*content*] -- Template variables (built-in and custom)
          2. [(site_name)] -- Settings tags
          3. {{chunk}} -- Chunk tags
          4. [[Cached_Snippets]]
          5. [+placeholders+]
          6. [!Uncached Snippets!]
          7. [~11~] -- Link tags
          8. [^t^] -- Timing tags

          What happens if you call the snippet uncached? I suppose it works the first time and than the page is cached.

          A solution would be to create a new snippet and test the id. Start here http://modxrules.com/articles/get-the-parent

            • 4229
            • 16 Posts
            Ah!

            Calling UltimateParent Cached seemed to do the trick. smiley I’ll test from another computer to be doubly sure it’ll work first time for everyone else but so far it seems to be working.

            Many thanks for the link to, I’ll look at that next.