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

    I want to run a ditto filter and exclude certain docs based on TV as opposed to ID - this will run to multiple clauses. Having some teething problems with this ...

    I have a container called ’Properties’ which will eventually contain at least 120 docs, and any doc could belong to at least 1 of 4 different categories - these are ’Available’ ’Managed’ HCP and ’A-Z’. I want to designate categories with a check-box TV.

    Thus far I’ve got a ’homepage’ for each category which renders all of the docs in the ’Properties’ container via an appropriate template - this is all fine. I want to exclude certain docs from the various category homepages based on whether the checkbox for that category is selected in the document. I’ve not used checkboxes with modx before and it’s not going to plan right now ...

    Initially I put 4 seperate checkbox TV’s in place but whatever value I set the checkbox to was neither saved nor reflected in the ditto result. I tried changing the default value for the checkbox but results were the same - wouldn’t save the value if it was changed.

    So I changed tack and created 1 checkbox TV [*property-classification*] with 4 different Input Option Values - this at least saves the checkbox changes, ie if selected or not, plus it saves space on the document page!
    The checkbox TV option values are:
    Available || Managed || HCP || A-Z

    To test this I tried filtering out any ’Managed’ docs from the A-Z homepage via this paramater:
    &filter=`property-classification,Managed,2`

    No joy.

    Can anybody pls advise as where I’m going wrong - looked in the Wiki etc. but there’s only reference to ID as the field rule.

    Thanks
      • 26931
      • 2,314 Posts
      Hi rootsdiv,
      try:
      Available==Available||Managed==Managed||HCP==HCP||A-Z==A-Z
        • 25519
        • 265 Posts
        Hi sharkbait
        Thanks for the feedback but no joy, although I can see exactly where you’re coming from.
        I reckon it’s gotta be something wrong with the ditto call as i beleive everything else is in place:

        > applied your input option values: Available==Available||Managed==Managed||HCP==HCP||A-Z==A-Z
        > all documents have relevant checkboxes ticked
        > tv is correctly referenced in ditto call (btw i changed that to [*property-status*])

        Here’s the ditto call on the A-Z page:
        [!Ditto? &parents=`12` &tpl=`a-z-List-Container_Alt` &filter=`property-status,Managed,2` &orderBy=`pagetitle ASC`!]

        This shows all of the docs in container 12 in alphabetical order, as would be expected, but no exclusion of the ’Managed’ docs huh
          • 16278
          • 928 Posts
          With filter mode 2, you are looking for equality, but if you have more than one box checked, that will never be true. Try just putting [*property-status*] into the body of your document ot see what is being returned as the values.

          &filter=`property-status,Managed,8` (to exclude docs that contain "Managed") might just work. (see http://ditto.modxcms.com/files/snippet-ditto-php.html#filter)
          smiley KP
            • 25519
            • 265 Posts
            Cheers KP, that hit the spot - so obvious really wink

            I plan to use multiple clauses to add more variants to which docs show, and thinking about it i reckon mode 8 makes sense.

            Happy Friday!
            rd