We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Actually it parses any placeholders that have been set already, I did test that, using both a snippet and another TV with @EVAL to set the placeholder. I used a placeholder to set the ID:
    $modx->setPlaceholder('document', 1);

    then used that placeholder in my @SELECT TV
    @SELECT * FROM [+PREFIX+]site_content WHERE id=[+document+]

    and it worked just fine.
      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
      • 8416
      • 173 Posts
      Now I’m really confused, I can’t get it to work and when I run the placeholder without quote I get a parsing error. How did you get it to work?
      @SELECT toursName, seats, fromDate, toDate FROM tnt_tours WHERE school=[+school+]

      I get a parsing error:
      « Execution of a query to the database failed - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[+school+]' at line 1 »
            SQL: SELECT toursName, seats, fromDate, toDate FROM tnt_tours WHERE school=[+school+]; 

      Note that I have to place the @SELECT statement in the default value field for the TV otherwise I don’t get any result using the widget datagrid....
      • I did exactly as I mentioned in my last post; the snippet/@EVAL TV (I tried this with both) setting the placeholder was called just before the @SELECT TV. Note that the value of [+document+] is an integer and so does not require single quotes. I’d better do some more research and figure out how to deal with strings, as well as variables in the original setPlaceholder function.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
        • Here’s exactly what I’ve done to verify this.

          1. Created a TV with a Data Grid output widget using this value (note the quote marks around the [+chunkid+] placeholder since this will be a string)
          @SELECT * FROM [+PREFIX+]site_htmlsnippets WHERE name='[+chunkid+]'

          2. Created a snippet that simulated using an array of values
          $ids = array();
          $ids['thischunk'] = 'sidebar1';
          $modx->setPlaceholder('chunkid', $ids['thischunk']);

          3. Put the snippet tags in a document, then the placeholder tags (just to check), then the TV tags.

          I got the appropriate display, which varied according to the name I set in the snippet.
          This is using using MODx 0.9.6.3 revision 4565, taken from SVN a few weeks ago.

          The function in the tmplvars.commands.inc.php file for processing the @SELECT command:
                      case "SELECT" : // selects a record from the cms database
                          $rt = array ();
                          $replacementVars = array (
                              'DBASE' => $modx->db->config['dbase'],
                              'PREFIX' => $modx->db->config['table_prefix']
                          );
                          foreach ($replacementVars as $rvKey => $rvValue) {
                              $modx->setPlaceholder($rvKey, $rvValue);
                          }
                          $param = $modx->mergePlaceholderContent($param);
                          $rs = $modx->db->query("SELECT $param;");
                          $output = $rs;
                          break;
          

          As you can see, it does use the $modx->mergePlaceholderContent function to merge any placeholders in the TV.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 20413
            • 2,877 Posts
            [+school+] output: Susan Ottwell wink
            *Bookmarked*
              @hawproductions | http://mrhaw.com/

              Infograph: MODX Advanced Install in 7 steps:
              http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

              Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
              http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower