We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19872
    • 1,078 Posts
    I am setting up about 10 TVs that will be checkbox, with the output of checked items to display in a list. Each list will have a Title on the webpage. Basically–columns of lists. Some lists will be longer. Others may only have one item in the list. I think I can handle the layout such that the content will look fairly balanced from a design sense.

    However, I am struggling to find an optimal approach to handle the selector aspect. What I would like to avoid is having a Title with no list below it. If no items are checked, I don't want reference to that list to appear on the web page.

    At the moment my plan is to create a TV for each category (i.e. Interior Features, Exterior Features, etc) , enter the checkbox items, and set the output to be HTML tag "li". Then create a chunk to contain the Title for the category along with the ul and li tags. In between the li tags, I'd put a call for the TV. Then, I'd create a TV selector for the TV—and call the chunk for the TV with the list of items. Seems like a lot
    of work just to make a TV optional to display on a page.

    A chunk would be called something like interiorFeatures_chunk
    A TV with all the available options to select would be called somehting like interiorFeatures_list
    A selector would be checkbox with input as: Show Interior Features==[[$interiorFeatures_chunk]]||==

    <h4>INTERIOR FEATURES</h4>
    <ul>
    [[*interiorFeatures_list]] <!--each checked/selected item outputs between li tags here-->
    </ul>


    Is my approach OK? Is there a better way to approach this?

    Another side question: What happens if I need to add and item to a checklist? Does that throw off all the checked items that have already been checked on existing resources?

    Any feedback, tips, suggestions, greatly appreciated.

    This question has been answered by Bruno17. See the first response.

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      In the first place, I'd use a MIGX TV, either a nested one with the outer grid for the categories and each category having its own inner grid, or a single TV for each category. You can have the working selection checkboxes in the grid, and add or remove items as needed.

      For the display, have the output block including the heading and the snippet in a chunk. Use an output modifier to only output the chunk if there is something to display. Something like

      [[[[*TVname:notempty=`$categoryChunk`]]]]
        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
        • 19872
        • 1,078 Posts
        Susan to the rescue! Yahoo!
        This is so much simpler than what I was thinking. MIGx could be a bit tricky, but that part I think I can handle. I've set up a few for image galleries, so starting to get the hang of it.
        Thank you.
          • 8274 ☆ A M B ☆
          • 222 Posts
          If MIGX becomes too daunting for you, you can look into the Listbox (Multi-Select) TV type http://rtfm.modx.com/revolution/2.x/making-sites-with-modx/customizing-content/template-variables/template-variable-input-types#TemplateVariableInputTypes-Listbox%28MultiSelect%29, Which would clean up the manager interface. This works if you are controlling what options are available in the lists.

          If the editor is going to be allowed to add items, then MIGX is really your best solution.

            • 19872
            • 1,078 Posts
            Hi Jason: I'll look into the Listbox (Multi-Select) TV type. Thanks for the link. Yes, MIGx is a bit daunting–though very nice when I'm able to make it work. I saw Susan also said this could just be done with individual TVs. More TVs, but manageable. Putting my TVs into categories certainly helps.

            My wife keeps telling me to do what I know (which isn't much, ha!). I'm stubborn though, and try something new each project in hopes that I will retain a smidgeon of knowledge.

            Thanks for the feedback. Much appreciated.
              • 19872
              • 1,078 Posts
              All is good! I'm using this method from Susan for now [[[[*TVname:notempty=`$categoryChunk`]]]]

              Question though:
              While most of my checkbox lists are relatively short—4 or 5 items, there are a couple that are really long. Is there a way to structure the input for the TV such that the checkboxes are in maybe 2 or 3 columns? Or is that more of a MIGx type of thing? [ed. note: mmcgee last edited this post 11 years, 7 months ago.]
                • 19872
                • 1,078 Posts
                Well, all is sort of good. Still trying to find any posts about splitting my long checkbox lists into columns as they are displayed in the manager.

                I created a chunk for my first feature – actually the longest one.

                <h5>INTERIOR</h5>
                <ul class="no-bullet">
                [[*propFeature_Interior]]
                </ul>


                Then I put this call on the template.
                [[[[*propFeature_Interior:notempty=`$propFeatureChunk_Interior`]]]]

                Even when no boxes are checked though, the chunk still loads and thus I end up with the title on the page. My impression was that if the TV is notempty, then the chunk would not load, and thus no title to worry about.

                ???
                  • 19872
                  • 1,078 Posts
                  Ah Ha!
                  The number of columns the checkboxes are displayed in.

                  Change to 3!

                  Still cannot figure out why noempty is not working though.

                  I tried restructuring the call to be:
                  [[*propFeature_Interior:notempty=`[[&propFeatureChunk_Interior]]`]]
                  This still loads the chunk even though no items are checked.

                  Docs show the string like this, but wouldn't the + indicate a placeholder? At any rate, this following yielded nothing on the page , even with items checked
                  [[+propFeature_Interior:notempty=`[[+propFeatureChunk_Interior]]`]] [ed. note: mmcgee last edited this post 11 years, 7 months ago.]
                    • 19872
                    • 1,078 Posts
                    This is driving me crazy.

                    I have output set to HTML tag li

                    Is that causing the TV to be notempty even though none of the checkboxes are checked?

                    If I cannot have an li in the output, then I don't really see a way to have the items display in list format.
                      • 19872
                      • 1,078 Posts
                      Must be the HTML Tag as the output. I changed the output to Default, and now the output modifier is working as expected. One small problem. The output of the checked items is 2nd KitchenBath Off MasterFrench Doors all strung together.

                      What do I do to get this output to appear as list?