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

    I use a number of drop down list menu TVs in my MODx site. Much of the data is obtained using @SELECT.
    @SELECT pagetitle,id FROM modx_site_content WHERE parent=20


    My problem is it’s impossible to select (and save) the value of the first item in the drop down box, unless the user selects the 2nd item from the drop-down and then selects the 1st item.

    Is there a way to get it to insert a blank-valued "Select an Option" line inserted as the default choice, so this problem doesn’t happen?
      MAPLEDESIGN MODX development and MODX web design and custom development. Proud to serve UK and International clients!
      • 27376
      • 576 Posts
      Change your query code to look like this:
      @SELECT 'Make a Selection' AS pagetitle, '-' AS id UNION SELECT pagetitle,id FROM modx_site_content WHERE parent=20
      Also, I recommend changing the hardcoded [tt]modx_[/tt] to [tt][+PREFIX+][/tt] like so:
      @SELECT 'Make a Selection' AS pagetitle, '-' AS id UNION SELECT pagetitle,id FROM [+PREFIX+]site_content WHERE parent=20
      That way, you can change your prefix in the future without trouble smiley

      You also might want to update your TV’s "Default Value" to "[tt]-[/tt]" (without the quotes) so your TV Content Values table doesn’t get cluttered.

      Enjoy!
      • Thanks! It seemed bizarre to add it onto the SQL query when all I wanted was it in the HTML, but it works smiley

        Regarding the prefix, the MODx docs on this site still say {PREFIX} which didn’t work hence the hard-coding. I’m glad to know what does work now, as I didnt’ like fixing it! Are the docs on this site dying (need documentation editors?)
          MAPLEDESIGN MODX development and MODX web design and custom development. Proud to serve UK and International clients!