We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9162
    • 39 Posts
    I’ve created a snippet that pulls data from a databse table and displays it in tabular format. The snippet takes an id as parameter, and this is added to the sql query.

    My problem is that if I’ve got more than 1 snippet call (sometimes need the tabular data for different id’s displayed on a page) on the same page, all table data is the same as the last database call that’s been made by the last snippet.

    What do I need to do to kinda not cache the snippet database calls and have them all display their own content?

    I’ve tried setting the page to no cache-able. Also used the [! !] brackets for the snippet calls, and even used the function_exists() method, but none of them helped.

    Please can someone help me?
    I’m using the release version of MODx evo, rev.5948

    thanks
    Ettiene
      • 26545
      • 3 Posts
      same problem here, only I use a snippet to generate my menu and the javascript for the menu. Which you should by all means put in the same snippet. I need two calls because the js goes into the header and the menu inside the body.
      I really like modxcms, but this "bug" seems really stupid. I don’t want to create two seperate snippets!

      Any ideas how to make two calls work? The first works the seconds doesn’t produce any output.
        • 5340
        • 1,624 Posts
        Did you tried to NOT cache the page?
        In the manager go to the second TAB and un-check Cache.
          • 26545
          • 3 Posts
          Yes, first thing I did ;-)
            • 3749
            • 24,544 Posts
            Are you using placeholders to display the data?
              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
              • 26545
              • 3 Posts
              *** FIXED ***

              by changing the following in the snippet code form:


              <?php
              /*
              ::::::::::::::::::::::::::::::::::::::::
              Example Usage:
              [[ImprintMenu? &action=`index`]]
              ::::::::::::::::::::::::::::::::::::::::
              */

              $menu_base = $modx->config[’base_path’]."assets/snippets/imprint_menu/";

              $ouput = "";

              include_once("{$menu_base}menu.inc.php");

              return $output;
              ?>

              into


              <?php
              /*
              ::::::::::::::::::::::::::::::::::::::::
              Example Usage:
              [[ImprintMenu? &action=`index`]]
              ::::::::::::::::::::::::::::::::::::::::
              */

              $menu_base = $modx->config[’base_path’]."assets/snippets/imprint_menu/";

              $ouput = "";

              include("{$menu_base}menu.inc.php");

              return $output;
              ?>

              meaning if you reverse engineer a new snippet from an existing one you should make sure you use include() instead of include_once(), if you want to make multiple calls :-D

              I don’t know if that would also fix ettiene’s problem though!