We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30176
    • 99 Posts
    I am using a Dropdown with a TV selecting the alias of resources to choose from to populate the TV.

    @SELECT pagetitle, alias FROM modx_site_content WHERE parent='235'  


    On occasion there are resources/documents that I desire to not have a value in this field. How does one have a resource that leaves that TV empty using a dropdown gathered with the above @Select statement? Thanks
      "Remember what Bilbo used to say: It's a dangerous business, Frodo, going out your door. You step onto the road, and if you don't keep your feet, there's no knowing where you might be swept off to."
      -J.R.R. Tolkien from The Lord of the Rings
      • 4310
      • 2,310 Posts
      If I understand you correctly, something like this?
      @SELECT pagetitle, alias FROM modx_site_content WHERE parent='235' AND (id NOT IN (625, 626, 627))

      Where 625, 626, 627 are the ID’s of the docs you don’t want in the TV dropdown.
        • 30176
        • 99 Posts
        Hi Bunk, Thank you for your example as I did not realize you could do that either. That is helpful. I do need to go a bit beyond this.

        What I would like is an empty default value for the TV followed by the list of TV values from the @Select. So I can choose to have no TV value or select one. If I had just a couple of TV values I could use a checkbox and not select a value. But with a dropdown I need an empty default value followed by my @Select binding list.

        In this case I have many variables--too many to use checkboxes--associated with the alias of firms that will have a TV value on either a product page, or article page or trade show event page, etc, etc. Yet, there are numbers of general pages that will not be associated with any firm. In using dropdowns because of the numbers of firms, though, I do not have an "empty" default value for general pages I do not want to put a TV value to. I could just use a separate template and not assign the TV to the general pages, but that seems awkward.

        i.e. TV = TVfirm

        TVfirm is the "alias" of 200 firms

        Article page -> TVfirm = 100
        General article -> TVfirm = No value
        product -> TVfirm = 102
        General Event Page -> TVfirm = No value
        Event Page -> TVfirm = 101, 102, 103, 104, 105, 106

        Hope this explains it better. smiley







          "Remember what Bilbo used to say: It's a dangerous business, Frodo, going out your door. You step onto the road, and if you don't keep your feet, there's no knowing where you might be swept off to."
          -J.R.R. Tolkien from The Lord of the Rings
          • 30176
          • 99 Posts
          Maybe I should ask the question just a little different way: With a @Select Binding to the TV using a multi-select dropdown how can it be set up to default to no value unless a value is selected? Now it is taking the first value in the select statement if I do not select anything upon document save.

          Thank you.
            "Remember what Bilbo used to say: It's a dangerous business, Frodo, going out your door. You step onto the road, and if you don't keep your feet, there's no knowing where you might be swept off to."
            -J.R.R. Tolkien from The Lord of the Rings
            • 4310
            • 2,310 Posts
            Shouldn’t do, unless you are setting a default value.
            If so try without, just using the @SELECT in the input options.
              • 30176
              • 99 Posts
              Thank you Bunk, You helpfulness is much appreciated! smiley After your message I went back and looked carefully at what I was doing. I did not have a default value, but I was using a "Dropdown List Menu" as the input type which if I did not select a value it was taking the first value in the dropdown from the @Select Binding.

              I changed the input type to ListBox (Multi Select) and now it does not take a value unless I select a value. So I am very pleased as it is working as I hoped and makes a big difference in how I design this site.

              I caused some confusion as I previously said multi-select dropdown which does not exist as either it is a "Dropdown List Menu" or "ListBox (Multi Select)".

              Thanks Again!
                "Remember what Bilbo used to say: It's a dangerous business, Frodo, going out your door. You step onto the road, and if you don't keep your feet, there's no knowing where you might be swept off to."
                -J.R.R. Tolkien from The Lord of the Rings
                • 4310
                • 2,310 Posts
                Got there in the end grin
                  • 26931
                  • 2,314 Posts
                  to leave the first value of a dropdown TV empty, something like this works:
                  @SELECT '' AS alias FROM modx_site_content UNION SELECT alias FROM modx_site_content WHERE parent=235
                    • 30176
                    • 99 Posts
                    Thanks Sharkbait, I am putting that in my toolbox.
                      "Remember what Bilbo used to say: It's a dangerous business, Frodo, going out your door. You step onto the road, and if you don't keep your feet, there's no knowing where you might be swept off to."
                      -J.R.R. Tolkien from The Lord of the Rings
                      • 28000 ☆ A M B ☆
                      • 397 Posts
                      I tried this code in Revo, but it did not work. I too use @select to populate a dropdown list (Listbox) in the manager:
                      @SELECT value FROM `modx_site_tmplvar_contentvalues` WHERE tmplvarid = 41

                      It works correctly, but how can I add an empty value at the top, which allows the admin to basically deselect a value..so as to send the TV an empty value? For the case where you do not wish to assign a value to this TV?

                      Thanks
                        Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.