We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39988
    • 5 Posts
    First, I'm new to ModX, but loving it so far. I have a quick question about methodology.

    What is the best method of creating a simple list/array that can be managed via the manager GUI?

    For example a list of countries (or list of projects, list of clients, list of services) for a drop-down menu. It seems like overkill to create each of these items as a documents. The other option would be to create snippet and parse that for each use, but that isn't quite as user-friendly for the people who will maintain the list.

    The lists will be used throughout the website on many of the pages, they are not items that have their own pages ... i.e. there is not a page for each country.

    Is there a good add-on for something like this?

    Many thanks to the ModX community for your help.
      • 4172
      • 5,888 Posts
      If you are on revo you can do it with some MIGX-TVs and let the included snippet getImageList create the select-options.

      you would create special Resource with a special Template and you would add all 'List-MIGX-TVs' to that Template, so you have them in the resource-editor of that Resource.

      The MIGX-TV configured with one or more fields for your select-options, its very easy to add, remove,resort options for each select-box.

      The same could be done with your projects,countrys and so on in custom-tables and with MIGXdb either as a TV or as customManagerPages.

      [ed. note: Bruno17 last edited this post 14 years, 4 months ago.]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 39988
        • 5 Posts
        Bruno17,

        Thanks for the reply. I did download and install the add-on, set up as the documentation instructs. This is a terrific add-on that will come in very handy at some point, but this seems like more overkill than using a resource. Is there really no way in ModX to just make a simple, one dimensional list? I guess a custom resource type must be created first?

        Thanks for your help.
          • 33337
          • 3,975 Posts
          You can use simple chunk for static list content?
            Zaigham R - MODX Professional | Skype | Email | Twitter

            Digging the interwebs for #MODX gems and bringing it to you. modx.link
            • 4172
            • 5,888 Posts
            To use MIGX for lists like that is not that overkill as you would think.

            Try this:

            Create an empty template 'MIGX_lists' for example
            Create a new MIGX-TV 'MIGX_list'

            Formtabs:
            [{"caption":"Option", "fields": [{"field":"option","caption":"Option"}]}]


            gridcolumns:
            [{"header": "Option","sortable": "true", "dataIndex": "option"}]


            Then create a new folder in the Resource-tree 'MIGX-lists'
            and for each list a new Resource under that folder, template: MIGX_lists

            for example a Resource 'Countries'
            Here you can add all Countries into the MIGX-TV, all items are stored as a Json-string into that TV

            to create a Countries dropdown on the frontend you would do just this:

            <select name="countries">
            [[getImageList? 
            &tpl=`@CODE:<option value="[[+option]]">[[+option]]</option>` 
            &tvname=`MIGX_list` 
            &docid=`theIDofYourCountriesResource`]]
            </select>


            this way you can add as many select-option-lists as your want, just by creating a new Resource.
            To add new options to your lists, just open the Resource and edit the MIGX-TV.
            [ed. note: Bruno17 last edited this post 14 years, 4 months ago.]
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 3749
              • 24,544 Posts
              You can also create a simple list type Template Variable for each of the lists, though MIGX would probably be more efficient.

              The Input Option Values for a countries TV would look like this, for example:

              USA||Canada||Ireland||Mexico



              ------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using.
              MODX info for everyone: http://bobsguides.com/modx.html

                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 813 ☆ A M B ☆
                • 326 Posts
                To piggyback on what Bob said about using TVs (which I think is the simplest method for what you're trying to do), there's some additional syntax you can use for setting both a display name and a form value, which looks like this:

                United States==usa||Canada==canada||Ireland==ireland||Mexico==mexico


                I somehow missed that when I was getting started. That documentation is here: http://rtfm.modx.com/display/revolution20/Template+Variable+Input+Types#TemplateVariableInputTypes-Listbox%28SingleSelect%29
                  • 9102 ☆ A M B ☆
                  • 318 Posts
                  I had thought the same thing initially about using a TV with the input type of single select list, but I think Shelton wants to display the drop-down on the front end and manage the options from the back end. For that I think the MIGX solution works best. A regular TV would give you a drop-down list on the back end, but on the front end it would just display the single selected value.

                  Another possibility would be using a custom DB table with a CMP, but I think that would indeed be massive overkill for this purpose.