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 have a TV named 'year'. I want to make a dropdown with all the years that have been used in that TV.
    so i need to do a DISTINCT query on the table tmplvar_contentvalues where tmplvarid=7 to retreive all possible entries.
    But i haven't got a clue how to do that? and i can't find a lead in these forums (fora) as well
    also because i hope to use standard Modx methods to make sure my query is sanitized /secure.

    any ideas

    RDG
      • 44234
      • 219 Posts
      A simpler solution for you might be to change it to an 'Auto-Tag' TV:

      http://rtfm.modx.com/display/revolution20/Template+Variable+Input+Types
        Find me on Twitter, GitHub or Google+
        • 24629
        • 370 Posts
        Hi
        Tnx for the reply a lot has been built and used allready so i'd rather stick to what we have now.
        Also i need this in an snippet to build the dropdown of a form. so i still need to know how to do that query.
        Good tip thought hadn't thought of that
        Rdg
          • 24629
          • 370 Posts
          Can anyone help?
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            @SELECT is not as flexible as coding for a snippet. I'm not sure that you can use xPDO "properly" here. This should do what you want:
            @SELECT DISTINCT value FROM [[+PREFIX]]site_tmplvar_contentvalues WHERE tmplvarid = 7
              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