We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7923
    • 4,213 Posts
    Something like:

    [+phx:if=`[*parent*]`:is=`6`:then=`{{chunkname}}`+]

    That would display the contents of chunkname if the document parent is 6.. if you want it to work on all documents that are under 6, you would use:

    [+phx:if=`[!UltimateParent!]`:is=`6`:then=`{{chunkname}}`+]

    UltimateParent is a snippet that you can find from resource repository or search for the newer version from forums (2.0). And chunks can have snippet calls.


      "He can have a lollipop any time he wants to. That's what it means to be a programmer."
      • 10573
      • 101 Posts
      Thanks. When I get it working, I’ll update the wiki since it wasn’t that clear to me that you could use other snippets.
      I’m all about improving the documentation and I’ll try to do my part.
        • 7923
        • 4,213 Posts
        Yes, that would be great, thanks for your efforts!


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 10573
          • 101 Posts
          I tried a couple of tests.

          Parent Document ID = 1
          - Child Document ID = 2

          I created the following chunks:
          {{ParentChunk}} = This is the ParentChunk Output
          {{ChildChunk}} = This is the ChildChunk Output

          I put the following code in the parent document and the child to check the results.

          [+phx:if=`[*parent*]`:is=`1`:then=`{{ChildChunk}}`:else=`{{ParentChunk}}`+] : Parent value = [*parent*]<br />
          [+phx:if=`[!UltimateParent!]`:is=`1`:then=`{{ChildChunk}}`:else=`{{ParentChunk}}`+] : UltimateParent Value = [!UltimateParent!]


          I got the following output on the page.

          Document ID = 1
          This is the ParentChunk Output : Parent value = 0
          This is the ParentChunk Output : UltimateParent Value = 1

          - Child document ID = 2
          - This is the ChildChunk Output : Parent value = 1
          - This is the ParentChunk Output : UltimateParent Value = 1

          It looks like I have to use the first line of code to accomplish what I am looking for smiley
            • 7923
            • 4,213 Posts
            If you use the first one, it won’t work for all the child documents (if you have more than one level). You could do something like:

            [+phx:if=`[!UltimateParent!]`:is=`1`:and:isnot=`[*id*]`:then=`{{ChildChunk}}`:else=`{{ParentChunk}}`+]


              "He can have a lollipop any time he wants to. That's what it means to be a programmer."
              • 18830
              • 161 Posts
              For a website I need a really big form with tons of input fields. I’m using eForm. For the body of the eMail I want to hide any empty input field or rather the label.

              I tried this PHx-code. If I got the documentation right, this should work with non-phx snippet templates.

              [+phx:input=`[+name+]`:isnot=``:then=`Name: [+name+]`:else=``+]


              Unfortunatly this won`t work with an eMail generated by eForm.

              The output of PHx will become

              [+phx:input=`John Doo`:isnot=``:then=`Name: John Doo`:else=``+]


              What is still worse: Any placeholder defindes in the eForm call will become deleted.

              Is there any way to get PHx working together with eForm?

              Or must I write some custom snippets?

              Thanks for any help.
                • 18830
                • 161 Posts
                I had some more tests, and maybe I found a bug:

                When PHx is active, then there will be a problem with eForm. PHx will delete all eForm-placeholders in the eForm-snippet even if you don’t use it at the eForm-chunks:

                Example: If you have an eForm-call like this

                [!eForm? ... &from=`[+email+]` !]


                then the from-field at the email will be empty.

                [!eForm? ... &from=`eMail` !]


                will work.
                  • 1261
                  • 27 Posts
                  I’m having trouble getting conditionals in PHx to work. I just downloaded PHx from ms.com/PHx-1006.html and installed it into my ModX .95. Things like [+phx:userinfo=`username`+] work correctly, so I know I have actually installed PHx, but the following snip of code outputs nothing:

                  [+rc.headerimg:isnot=``:then=`{{rc.imgheader}}`:else=`{{rc.noimgheader}}`+]

                  The idea is that I have a template variable called [*rc.headerimg*] that’s either (well, @INHERIT) or contains the URL to an image. If the TV is blank, then I want PHx to display a snippet called {{rc.noimgheader}} which is, well, the header without an image. Otherwise, I want it to display a snipped called {{rc.imgheader}} which is the same header but with an image in the background.

                  Any idea what I’m doing wrong?
                    • 4195
                    • 398 Posts
                    Quote from: Alterscape at Feb 06, 2007, 06:58 PM

                    [+rc.headerimg:isnot=``:then=`{{rc.imgheader}}`:else=`{{rc.noimgheader}}`+]

                    ... I have a template variable called [*rc.headerimg*] ...

                    it’s a tv so the tag format in your example is the problem.. correct would be:

                    [*rc.headerimg:isnot=``:then=`{{rc.imgheader}}`:else=`{{rc.noimgheader}}`*]
                    
                      Armand Pondman
                      MODx Coding Team
                      :: Jot :: PHx
                      • 4195
                      • 398 Posts
                      PHx 2.1.2 is here!
                        Armand Pondman
                        MODx Coding Team
                        :: Jot :: PHx

                      This discussion is closed to further replies. Keep calm and carry on.