We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37638
    • 63 Posts
    I am having issues with Revo 2.2.6 where a chunk taking a snippet in a parameter isn't working.

    Following content (in template that is only [[*content]]:

    [[!sql? &tpl=`cnt` &query=`SELECT name as cnt from modx_pcm_companies WHERE companies_id='27'`]]
    
    [[$testChunk? 
    &newModalId=`addPMC`
    &middleHeaderUnits=`PMCs`
    &showThirdBox=`0`
    &middleHeaderTitle=`[[!sql? &tpl=`cnt` &query=`SELECT name as cnt from modx_pcm_companies WHERE companies_id='27'`]]`
    ]]


    Outputs:
    SELECT name as cnt from modx_pcm_companies WHERE companies_id='27'
    
    addPMC
    
    
    PMCs
    0


    Right now, sql snippet is just:
    <?php
    return $output . $query;


    And test chunk is:
    [[+newModalId]]
    [[+middleHeaderTitle]]
    [[+middleHeaderQty]]
    [[+middleHeaderUnits]]
    [[+showThirdBox]]


    Why won't the snippet return show up in the chunk (line 2)?
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      Does it make a difference if you call the sql snippet uncached in the chunk call?
        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.
        • 37638
        • 63 Posts
        It does! It works if the second is called uncached.

        What is going on?
          • 4172
          • 5,888 Posts
          try to change cached/uncached tags:

          [[sql? &tpl=`cnt` &query=`SELECT name as cnt from modx_pcm_companies WHERE companies_id='27'`]]
           
          [[$testChunk?
          &newModalId=`addPMC`
          &middleHeaderUnits=`PMCs`
          &showThirdBox=`0`
          &middleHeaderTitle=`[[sql? &tpl=`cnt` &query=`SELECT name as cnt from modx_pcm_companies WHERE companies_id='27'`]]`
          ]]


          only if you need it really uncached try this:

          [[!sql? &tpl=`cnt` &query=`SELECT name as cnt from modx_pcm_companies WHERE companies_id='27'`]]
           
          [[!$testChunk?
          &newModalId=`addPMC`
          &middleHeaderUnits=`PMCs`
          &showThirdBox=`0`
          &middleHeaderTitle=`[[!sql? &tpl=`cnt` &query=`SELECT name as cnt from modx_pcm_companies WHERE companies_id='27'`]]`
          ]]
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 37638
            • 63 Posts
            I just did a happy dance, literally. This fixed another problem on the same site, I was about to pull my hair out.

            So, how do I avoid the content being cached? Just mark the page as uncachable?
              • 22303 MODX Staff
              • 10,725 Posts
              Use ! to control what is not cached on the Resource after the first request is made to it. You should rarely completely disable caching of a Resource except perhaps when in development.
                • 37638
                • 63 Posts
                So, if I don't want any of the [[sql?]] snippets cached, but using ! twice in a resource throws stuff off, what are my options? Or am I misunderstanding the use of ! ?
                  • 22303 MODX Staff
                  • 10,725 Posts
                  Quote from: jmaddington2 at Jan 09, 2013, 10:10 AM
                  So, if I don't want any of the [[sql?]] snippets cached, but using ! twice in a resource throws stuff off, what are my options? Or am I misunderstanding the use of ! ?
                  I think you are just misunderstanding. Anything that should not be cached can and should be marked with the exclamation point. @Bruno17 provided this as the second example of his reply...
                    • 37638
                    • 63 Posts
                    So, in the case of my first post all the snippet is supposed to do is return the &query parameter sent to it. Why does it work the first, but not the second?

                    Under the "Outputs" section, lines 1 and 4 should be the same. Instead, I have to call sql uncached to get it to show up the secont time.