We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24629
    • 370 Posts
    Hi All,
    I’ve got a TV that works fine with an @SELECT binding. The select gets the correct values for the istbox.
    @SELECT `pagetitle` AS `name`,`id` FROM `[[+PREFIX]]site_content` WHERE `parent` = 2 AND `deleted` = 0

    Now i want to make the parent ID dependent on the Language TV which is is also available in my template
    so i tried :
    @EVAL [[Snippet-that-returns-correct-@SELECT]];

    But i cant get it to work
    so can this be done? and how
    I’m using REVO 2.0.7pl

    tnx
    RDG
      • 4172
      • 5,888 Posts
      you can run a snippet with @EVAL - binding like that:

      @EVAL return $modx->runSnippet('mysnippet');
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 29019 ☆ A M B ☆
        • 104 Posts
        Quote from: Bruno17 at Mar 16, 2011, 07:11 AM

        you can run a snippet with @EVAL - binding like that:

        @EVAL return $modx->runSnippet('mysnippet');


        If your trying to get the query out of your snippets, not the results, you can try @SELECT in front of your @EVAL, but I’m not sure the parser is that sophisticated for template variable options. You’d probably be better off putting the whole thing in a snippet.
          www.darkstardesign.com

          Are you in the Nashville area? Join us for our next MODX meetup!
          • 24629
          • 370 Posts
          Hi,

          You’re right the select statement is not parsed. so i’m trying to do the select in the snippet

          // Snippet "rechtsgebiedenChooser" used in TV "rechtsgebieden" as @EVAL return $modx->runSnippet('rechtsgebiedenChooser');
          $lang  = $modx->resource->getTVValue('language');
          $output = '';
          
          if ($lang == 'nl'){
              $par = 2;
          }else if($lang == 'en'){
               $par = 41;
          }
          
          $coll = $modx->newQuery('modResource');	
          $coll->where(array('parent' => $par, 'deleted'=>'0'));
          	
          $rechtsgebieden = $modx->resource->getMany('Children',$coll);
          	foreach ($rechtsgebieden as $rechtsgebied){
          		 $output .= $rechtsgebied->get('id').",".$rechtsgebied->get('name');
          	}
          
          
          return  $output;

          I suspect the $lang is empty. Is it possible to get an another TV value form the document in an BINDING?


          tnx RDG