We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39548
    • 10 Posts
    MODX version 2.3.3-pl
    In a MODX template i am calling a chunk and inside that chunk i am using a conditional statement to check if it is the home page or resource 1, if so then lets show something. In this case the output should output some settings to the screen.
    This seems to work fine until i add the &data=`a?`, now the 'a' can be any length of characters or whitespace with characters, once adding the '?' all code gets removed including the div with id of settings-wrapper.
    if i remove all characters and just leave the '?' it works ok, I have changed the &data to &shawn=`a?` and got the same results. Also if i add any characters or whitespace after the '?' not having any thing in front of it there is no problem

    Fails
    [[*id:is=`1`:then=`
        <div id="settings-wrapper" style="min-height: 50px;">
        [[!_utility? &type=`settings` &data=`a?`]]
        </div>
    `]]	
    


    Works
    [[*id:is=`1`:then=`
        <div id="settings-wrapper" style="min-height: 50px;">
        [[!_utility? &type=`settings` &data=`?`]]
        </div>
    `]]	
    


    Works
    [[*id:is=`1`:then=`
        <div id="settings-wrapper" style="min-height: 50px;">
        [[!_utility? &type=`settings` &data=`?a`]]
        </div>
    `]]	
    


    Thanks
    Shawn

    This question has been answered by multiple community members. See the first response.

    • discuss.answer
      • 3749
      • 24,544 Posts
      A character followed by a question mark is tells the parser that arguments follow. If there is more than one such combo in a tag, the parser will get confused.

      If _utility is your own snippet, you can use some other character or character combination where you want the question mark (e.g., QQ) and translate it in the 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
        • 39548
        • 10 Posts
        Quote from: BobRay at May 22, 2015, 09:36 PM
        A character followed by a question mark is tells the parser that arguments follow. If there is more than one such combo in a tag, the parser will get confused.

        If _utility is your own snippet, you can use some other character or character combination where you want the question mark (e.g., QQ) and translate it in the snippet.

        So I would expect this outside of the '`' (ticks), but inside of the ticks i could be passing a title like &data=`How was your day?`, and when i remove the conditional statement it works fine
        Works
         <div id="settings-wrapper" style="min-height: 50px;">
            [[!_utility? &type=`settings` &data=`How was your day?`]]
            </div>
        


        But add the conditional statement and it fails
        [[*id:is=`1`:then=`
            <div id="settings-wrapper" style="min-height: 50px;">
            [[!_utility? &type=`settings` &data=`How was your day?`]]
            </div>
        `]] 
        
          • 3749
          • 24,544 Posts
          The MODX parser is very complex and I don't pretend I can explain it fully, but your second example has both a conditional output modifier and a nested tag. Either one (or the combination) could be causing the trouble, but the solution I suggested should solve the problem in any case.

          It will definitely be easier than re-writing the parser. 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
            • 39548
            • 10 Posts
            I just thought i would mention the issue, and yes im sure the parser is complex and there is probably a bit of black magic that goes on in there.
            Thanks again Bob, for your quick responses and helpful advice.
            Shawn
              • 3749
              • 24,544 Posts
              Good point. The trouble with parser issues, though, is that trying to fix them often causes other things to break.

              I'm glad you got it sorted. smiley
                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
              • discuss.answer
                Just for kicks, have you tried this?

                [[!*id:is=`1`:then=`
                    <div id="settings-wrapper" style="min-height: 50px;">
                    [[!_utility? &type=`settings` &data=`?`]]
                    </div>
                `]] 


                If my understanding of the parser is any good, the problem you're seeing is due to the parsing order. _utility is uncached, causing it to be processed later, and the [[*id]] processing taking place first, which is where the parser gets confused with the extra backticks and the question mark..
                  Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                  Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                  • 39548
                  • 10 Posts
                  Quote from: markh at May 24, 2015, 02:20 PM
                  Just for kicks, have you tried this?

                  [[!*id:is=`1`:then=`
                      <div id="settings-wrapper" style="min-height: 50px;">
                      [[!_utility? &type=`settings` &data=`?`]]
                      </div>
                  `]] 


                  If my understanding of the parser is any good, the problem you're seeing is due to the parsing order. _utility is uncached, causing it to be processed later, and the [[*id]] processing taking place first, which is where the parser gets confused with the extra backticks and the question mark..

                  Hi Mark, Thanks for the information, this worked.