We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12379
    • 460 Posts
    The only output I get for phx below is:

    `+]

    [+phx:if=`[!UltimateParent!]`:is=`9`:then=`{{test_chunk_1}}`:else:`[+phx:if=`[*id*]`:is=`9`:then=`{{test_chunk_1}}`:else=`{{test_chunk_2}}`+]`+]


    Have tested UltimateParent values ok.
      Mostly harmless.
      • 4172
      • 5,888 Posts
      try

      [+phx:if=`[!UltimateParent!]`:is=`9`:then=`{{test_chunk_1}}`:else=`[+phx:if=`[*id*]`:is=`9`:then=`{{test_chunk_1}}`:else=`{{test_chunk_2}}`+]`+]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 12379
        • 460 Posts
        yup, i’d tried that - same result...
          Mostly harmless.
          • 3749
          • 24,544 Posts
          Quote from: Bruno17 at Jul 28, 2010, 04:33 AM

          try

          [+phx:if=`[!UltimateParent!]`:is=`9`:then=`{{test_chunk_1}}`:else=`[+phx:if=`[*id*]`:is=`9`:then=`{{test_chunk_1}}`:else=`{{test_chunk_2}}`+]`+]


          Time to write that snippet. wink

          [!PickChunk? &up=`[!UtimateParent!]` &id=`[*id*]`!]

          <?php
          /* PickChunk snippet */
          
          if ($up == '9' || $id == '9') {
            $chunk = 'test_chunk_1';
          } else {
            $chunk = $modx->'test_chunk_2';
          }
          return $modx->getChunk($chunk);
          ?>


          Actually, you could do it in one line like this:

          <?php
          return $up == '9' || $id == '9'? $modx->getChunk('test_chunk_1') : $modx->getChunk('test_chunk_2');
          ?>
          


          I’m not sure which would be faster (probably the second), but either one should be infinitely faster and more efficient than PHX. PHX conditionals are very expensive.

          You could also send the names of the two chunks in the snippet call if you want to make it more general.
            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
            • 4172
            • 5,888 Posts
            doesn’t [!UltimateParent!] return the self-id if you are on UltimateParent?

            so may be that will do it?

            [+phx:if=`[!UltimateParent!]`:is=`9`:then=`{{test_chunk_1}}`:else=`{{test_chunk_2}}`+]
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 12379
              • 460 Posts
              Yes Bruno17 it does as I found out later when I called UltimateParent before phx to see what was happening so I used the same solution as you but it still didn’t work!

              BobRay - that last one is very slick. I tossed in phx and came up with:

              <?php
              $ultParent = $modx->runSnippet(’UltimateParent’);
              if ($ultParent == 9) {
              $output = ’{{test_chunk_1}}’;
              }
              else $output = ’{{test_chunk_2}}’;
              return $output;
              ?>
                Mostly harmless.
                • 3749
                • 24,544 Posts
                Quote from: hotdiggity at Jul 28, 2010, 11:04 AM

                Yes Bruno17 it does as I found out later when I called UltimateParent before phx to see what was happening so I used the same solution as you but it still didn’t work!

                BobRay - that last one is very slick. I tossed in phx and came up with:

                <?php
                $ultParent = $modx->runSnippet(’UltimateParent’);
                if ($ultParent == 9) {
                $output = ’{{test_chunk_1}}’;
                }
                else $output = ’{{test_chunk_2}}’;
                return $output;
                ?>

                I’ll be pretty surprised if that works, since you can’t use MODx tags in a snippet. This should work, though (if UltimateParent will work with no parameters):

                return = $modx->runSnippet('UltimateParent') == 9? $modx->getchunk('test_chunk_1'): $modx->getchunk('test_chunk_2') ;
                  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
                  • 12379
                  • 460 Posts
                  My snippet works (if that’s what you were referring to).

                  D’oh - just discovered the programmer working on different part of the site disabled phx!! Sorry!
                    Mostly harmless.
                    • 3749
                    • 24,544 Posts
                    Quote from: hotdiggity at Jul 29, 2010, 12:00 AM

                    My snippet works (if that’s what you were referring to).

                    D’oh - just discovered the programmer working on different part of the site disabled phx!! Sorry!

                    Yes it does. I didn’t notice that you were returning the chunk tags in a string -- the dangers of speed reading. wink
                      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
                      • 12379
                      • 460 Posts
                      Know the feeling!
                        Mostly harmless.