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

    I’m trying to figure out if it is possible to get a list of all possible values of a certain TV. For example, I have a TV (DropDown List) called "GamesGenre" which includes values like "Action||Action-Adventure||Strategy||Jump’n’Run". This TV is assigned to a special template to classify the content, but now I want to get all(!) those possible values on another part of my site. Is this possible to do?

    Hope somebody can help me.
    Thanks! smiley
      L.net Web Solutions
      Professional webdesign and development with MODX and WordPress.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Presuming these are all set in resources, you could use
      SELECT DISTINCT value FROM $modx->getFullTableName('site_tmplvar_contentvalues') where tmplvarid = 7

      This query would return all the possible values for the TV with the ID of 7. This presumes you know the ID of the TV that holds the values in question. I’m sure the MySQL gurus here can produce a query with a left join on something-or-another where you can use the TV name; I’m too lazy on this hot afternoon to go that far!
        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
        • 21078
        • 77 Posts
        Thank you! I played around with your code and now I use the following snippet to get all the elements of my TV:

        $output = '';  
        $result = $modx->db->query('SELECT elements FROM `modx_site_tmplvars` WHERE id = 47 LIMIT 1');
        while($row = $modx->db->getRow($result)) {  
            $output = $row['elements'];
        }  
        return $output;


        Next step will be to format the output the way I need it to be, but that should be no problem smiley
          L.net Web Solutions
          Professional webdesign and development with MODX and WordPress.