We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23183
    • 102 Posts
    Im having a bit of trouble using the &filter with Ditto.

    I have two template variables ’menslist’ and ’womenslist’ and I want to remove documents where ’[*storetitle*] is not present in either of those TV’s. my statement is
    &filter=`menslist,[*storetitle*],7|womenslist,[*storetitle*],7`

    But it is showing only the documents where [*storetitle*] is present in both TV’s

    I read this in the documentation:

    Multiple clauses have an "OR" relationship. I.e. a document will be excluded if it meets the criterion of any one clause (clause-1 OR clause-2 OR clause-3, etc.).

    So had hoped it would show documents where storetitle is present in ’menslists’ OR ’womenslist’ not AND.

    Anyway I can get around this?

    Many Thanks.

      • 16278
      • 928 Posts
      Filters exclude when the condition is true - so by using mode 7 you are asking for documents to be excluded if storetitle is not in menslists or is not in womenslists or is not in either. Mode 8 should produce the result you are seeking.
      smiley KP
        • 23183
        • 102 Posts
        Thanks for the reply KP52

        I need to display dosuments where [*storetitle*] is present in either menslist or womenslist. Therefore by using mode7 it excludes the documents where [*storetitle*] is not present and gives me the desired result.

        The problem I am having is with the multiple clauses and the documents that are getting left are those that have [*storetitle*] in the menslist AND womenslist rather than leaving documents that have [*storetitle*] in menslist OR womenslist.
          • 11055 ☆ A M B ☆
          • 3,112 Posts
          I think your Mode 7 is right.
          &filter means "taking out from the result".
          The problem was the arrangement: &filter=`storetitle,menslist,7|storetitle,womenslist,7`
            Rico
            Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
            MODx is great, but knowing how to use it well makes it perfect!

            www.virtudraft.com

            Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

            Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

            Maintainter/contributor of Babel

            Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
            • 23183
            • 102 Posts
            Thanks for the relpy goldsky, I tried that aswell and it didnt work. I think the way I had it is the correct order

            menslist and womenslist are the name of two template variables. ’storetitle’ is another TV and I need to get the value from that TV so its: [*storetitle*]

            So the field is menslist/womenslist and the criterion is the value of [*storetitle*]

            field,criterion,mode.

            For some reason though it is removing all documents except those where the [*storetitle*] is present in both the menslist and womenslist TV.
              • 4172
              • 5,888 Posts
              why not using two ditto-calls?
              [!Ditto? &filter=`menslist,[*storetitle*],7`!] 
              [!Ditto? &filter=`womenslist,[*storetitle*],7`!]


              or if you want to have them together in one call you can try:

              [!Ditto?.............. &documents=`[[Ditto?................&display=`all`&noResults=`999999,` &filter=`menslist,[*storetitle*],7`&tpl=`@CODE:[+id+],`]][[Ditto?............. &display=`all`&noResults=`999999,`&filter=`womenslist,[*storetitle*],7`&tpl=`@CODE:[+id+],`]]`!]
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 23183
                • 102 Posts
                Thanks for the suggestion Bruno, As some values are included in both the mens and womens lists if I used two seperate ditto calls I would get duplicate documents listed where the value appears in both. I think anyway unless there is a work around?

                Would the bottom method get the same results?
                  • 1122
                  • 209 Posts
                  The issue of logical AND/ OR in Ditto’s filter is fully solveable through the rules of Boole’s arithmetics alone -> http://modxcms.com/forums/index.php/topic,39966.msg242257.html#msg242257
                    • 23183
                    • 102 Posts
                    Thanks for the reply Alik,

                    Would it be possible to explain it a little clearer, after looking at your other post it seems I am following the rule. I am trying to throw out the documents that do not contain [*storetitle*] in either menslist or womenslist, so I should be left with those that do. However I am left with those that contain [*storetitle*] in both menslist and womenslist, the documents that have [*storetitle*] in JUST the menslist or JUST the womenslist are getting thrown out.
                      • 1122
                      • 209 Posts
                      I have read carefully all this thread and learned that actually you need to _obtain_ docs whose menslist TV contains specifi value or whose womenslist TV contains specific value. This, unfortunately, cannot be achieved through Ditto’s filter, because it throws out docs thus producing final logical AND. For you case, Bruno’s bottom suggestion is right -- I tried to put it in order:
                      [!Ditto? &documents=`[[Ditto? &parents=`where-to-start-search` &display=`all` &noResults=`999999,` &filter=`menslist,[*storetitle*],7` &tpl=`@CODE:[+id+],`]]` &display=`all` &filter=`womenslist,[*storetitle*],7` &tpl=`your-template-to-show-docs`!]
                      

                      Parsing starts from internal Ditto call and returns docs containing required value in menslist, next the entire list is filtered by outside Ditto for the required value in womenslist. You need to adjust "where-to-start-search" and "your-template-to-show-docs".