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

    I have a checkbox which shows the facilities of a property, but im not too sure how to output each checkbox that is selected against the document.

    TV is called Facilities
    my Input option values are:

    Rooms with En Suite==0||Heated Indoor Swimming Pool==1||Sauna==2||Exercise Studio==3||Treatment Room==4||Outdoor Swimming Pool==5


    all I would like to do is to output the selected checkboxes into a list and display them.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      What kind of output options did you set for the TV?
        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
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        By the way, if you want the labels when editing the resource's TV to be the same as the output in the page on the front-end, don't use the == part. Just
        Rooms with En Suite||Heated Indoor Swimming Pool||Sauna||Exercise Studio||Treatment Room||Outdoor Swimming Pool

        will do both the same.
          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
          • 47401
          • 295 Posts
          Quote from: sottwell at Dec 04, 2015, 12:23 AM
          What kind of output options did you set for the TV?
          Hi

          Ive left the output as Default. Should I change this to something else?
            • 47401
            • 295 Posts
            Quote from: sottwell at Dec 04, 2015, 01:13 AM
            By the way, if you want the labels when editing the resource's TV to be the same as the output in the page on the front-end, don't use the == part. Just
            Rooms with En Suite||Heated Indoor Swimming Pool||Sauna||Exercise Studio||Treatment Room||Outdoor Swimming Pool

            will do both the same.
            ive used keys on purpose as I assumed that using 0== 1== would give me an array to work with?
              • 47401
              • 295 Posts
              ok ive changed the output to delimiter and used comma in the box. when I output the tv it now displays the id's in a cvs format.

              i guess I could now create a snippet and using php reference the TV as a php variable, then use php explode() on the variable. this may work
                • 47401
                • 295 Posts
                another problem ive found is that the starting checkbox in the TV 'facilities' is not outputted even when selected within the document. php arrays start as 0, does checkboxin modx key need to start as 1?
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  If you use an HTML element output type, with the HTML tag as "li", then it will output a list (you'll have to supply the enclosing UL tags around the TV tags).

                  Or if you use a delimiter output type, specifying a comma, you'll get a comma-delimited list.

                  All the key-value method does is provide a different label for the checkboxes, while their values will be the second part. It just depends on what you want to do with the TV's content.

                  Here's what's saved in the database with just the values, no key-value:
                  Rooms with En Suite||Heated Indoor Swimming Pool||Sauna||Exercise Studio||Treatment Room||Outdoor Swimming Pool

                  And here's what's saved in the database with key->value input options:
                  1||2||3||4||5

                  So only the values are saves as a string using || as the default delimiter. The output options break down the string and process it according to the option chosen. Notice the one with the value of 0 isn't saved at all. [ed. note: sottwell last edited this post 10 years, 9 months ago.]
                    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
                    • 4172
                    • 5,888 Posts
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 47401
                      • 295 Posts
                      Quote from: sottwell at Dec 04, 2015, 03:20 AM
                      If you use an HTML element output type, with the HTML tag as "li", then it will output a list (you'll have to supply the enclosing UL tags around the TV tags).

                      Or if you use a delimiter output type, specifying a comma, you'll get a comma-delimited list.

                      All the key-value method does is provide a different label for the checkboxes, while their values will be the second part. It just depends on what you want to do with the TV's content.

                      Here's what's saved in the database with just the values, no key-value:
                      Rooms with En Suite||Heated Indoor Swimming Pool||Sauna||Exercise Studio||Treatment Room||Outdoor Swimming Pool

                      And here's what's saved in the database with key->value input options:
                      1||2||3||4||5

                      So only the values are saves as a string using || as the default delimiter. The output options break down the string and process it according to the option chosen. Notice the one with the value of 0 isn't saved at all.

                      Hi Thanks again

                      Ok Ive changed the input option as per your above recommendation, and also changed the output option to HTML Tag. This time is now produces a list, but still only outputs the keys and not the values. How can I output the values of each checkbox?