We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10960
    • 2 Posts
    I’ve run into somewhat of a problem when trying to use PHx conditions as a boolean switch to change Chunks.

    Example:
    [+user.boolean1:is=`1`:then=`
    {{chunk1}}
    `:else=`
    [+user.boolean2:ne=`1`:then=`
    {{chunk2}}
    `+]
    `+]

    This set of PHx conditions works perfectly with straight HTML or text but fails with Chunks. Instead of the expected result, it displays the placeholders, conditions and both Chunks on the page.

    Each Chunk contains some Javascript, HTML, a form and a Snippet of PHP that processes the form into a MySQL DB.

    Is this something that usually occurs? Is there a workaround? Am I doing something wrong?

    Thanks, Gordon MacK.

    PS. I did a bit of a search before making this post and only found one person with a similar problem, unfortunately no real solution was found.
      • 3749
      • 24,544 Posts
      You might try putting the whole thing on a single line, but I suspect that the PHX parser can’t handle the nested back-ticks in the else condition. I suspect that it’s being parsed like this:

      else=`[+user.boolean2:ne=`
      1`:then=`
         {{chunk2}}


      I could be wrong.

        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
        • 10960
        • 2 Posts
        Single line makes no difference, I broke it up to make it more readable for the forum.

        Due to a tight deadline I used a snippet and some PHP to do work around which does everything I need it to.

        PHx seems like a big pile of fail, I’ve run into so many problems with it.
          • 3749
          • 24,544 Posts
          A snippet is *much* faster and uses way fewer resources than a complex PHX conditional. I would have used a snippet to begin with.

          In Revolution, the PHX-like output modifiers are built into MODx. They’re more efficient, but a snippet is still a better choice than a complex conditional statement. PHX is nice for people who need something in a hurry, don’t care about the speed and resources, need a convenient way to format a date, and/or don’t have the coding skills to use a snippet.

            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