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've use selectors in the past for displaying various TVs, but wondering about alternative options. I have a series of 7 or 8 TVs, each with varying amounts of checkboxes—lots of checkboxes. In some cases, all of the TVs will have at least one box checked, but in others there may be some left unchecked and are not needed for display on the resource. Each TV would display on the resource with a Title and the checked items displayed as a list. If a certain category is not checked, then I don't want the title on the page with no list below.

    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>
    



    I'd be interested if anyone has another or better approach.
      • 19872
      • 1,078 Posts
      Or maybe all categories, headers, and the list of checkbox items could be contained in one big TV? Where the user checks a box to display a Title AND each optional check box, though I have no idea how or whether that could be done—or for that matter, how to get the output to be all separated out into the various h4 tags and lists

      Is this a task better completed using MIGx? And if so, could one MIGx TV be made to complete the task, or would I create a MIGx TV for each category?
        • 19872
        • 1,078 Posts
        I went to google to do a seach instead of searching through the forum and found some info related to output modifiers... Perhaps this is the way to go.

        [[+placeholder:is=`0`:then=`
             // code
        `:else=`
             // code
        `]]


        So if no items are checked – one set up code would display on the resource. else another set of code. So perhaps I could handle each TV like this?
        [[+placeholder:is=`0`:then=`
             // code I WOULD PUT NOTHING HERE. IF NOTHING CHECKED. NOTHING DISPLAYS.??
        `:else=`
             // code HERE I WOULD PUT MY TITLE TAG and THE TV CALL IN BETWEEN UL TAGS (TV would be set to HTML tag output with li instead of div)
           <h4>Title of My List</h4>
           <ul>
          [[*myList]]
           </ul>
        `]]


        Would this be good solution?
          • 19872
          • 1,078 Posts
          If a good solution... then, would I have to built a snippet for each, or can I put my conditional code right on my template?

            • 28042 ☆ A M B ☆
            • 24,524 Posts
            You can have a nested MIGX TV, the outer grid for the categories, and each category with its own grid.

            You could put each category block in a chunk, and use an Output Modifier to display the chunk (which would get processed on the next pass through the parser) if the given category isn't empty.
              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
              Hey Susan! I caught your other post. Sorry to double up on my forum posting. The forum has been eeeeerily quiet, and I am having a very difficult time getting the search aspect to work.
              Thank you again.