We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15877
    • 55 Posts
    Hello,

    I am using an SQL select in a TV to get the IDs of the children of a parent document.
    The query looks like this
    @SELECT `pagetitle` AS `name`,`id` FROM `modx_site_content` WHERE `parent` = 2 ORDER BY `pagetitle`


    The website is in two languages (FR and EN) and uses the same templates for both languages.

    So I need to set the parent above depending on the context : 2 for FR and 576 for EN.
    I use a lexicon call to do this on templates, but it does not seem to work in an SQL query.
    [[%id_home_artistes? &topic=`_website` &namespace=`core`]]


    How would you do this?
      • 40045
      • 534 Posts
      maybe with a nested @EVAL binding where you specify the parent. The @EVAL binding would return the correct parent id, e.g.

      @EVAL $res = $resource->get('context_key'); $parent = $res === 'web' ? 2 : 576; return $parent;
      
      // which would result in
      
      @SELECT `pagetitle` AS `name`,`id` FROM `modx_site_content` WHERE `parent` = @EVAL $res = $resource->get('context_key'); $parent = $res === 'web' ? 2 : 576; return $parent; ORDER BY `pagetitle`
      


      not really sure if this would work though...maybe you just switch to only an @EVAL binding completely...