We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19726
    • 239 Posts
    Hi, I am trying to create a snippet that shows some special things on a page when a TV has been set for a page.

    So I made an image TV and associated that to a template. Then I set up a few pages, some with the TV filled in some with the TV beeing empty. I am now trying to detect in my snippet when the TV is empty or not. For this I use the getTemplateVar function. It seemed to work OK, but not for cached pages. There I got the following SQL error

    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource: 
    « Execution of a query to the database failed » 
          SQL: SELECT tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value FROM `etomitejnz`.etomite_site_tmplvars tv INNER JOIN `etomitejnz`.etomite_site_tmplvar_templates tvtpl ON tvtpl.tmplvarid = tv.id LEFT JOIN `etomitejnz`.etomite_site_tmplvar_contentvalues tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '28' WHERE tv.name IN ('foto1') AND tvtpl.templateid = 
     


    The snippet has the following code (this is a testsnippet with all code needed to reproduce the problem)

    $temptv = $etomite->getTemplateVar(3);
    return 'OK - '.$temptv['value'];


    If I put this on a page like this [!test!] it works on non-cached pages, it does not work on cached pages. There I get the error message mentioned above. It is my understanding that when you put a snippet in [! !] brackets it should not be influenced by caching.

    Any ideas on what could be wrong?

    EDIT using [[ ]] brackets makes the problem go away. I made a thinking error when I thought I needed an uncached snippet, so my problem is solved for now, but I would still like to know why it didn't work.