We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23183
    • 102 Posts
    Thanks very much for the help alik & Bruno,

    my old ditto call was this:

    [!Ditto? &startID=`3` &tpl=`brandsite` &display=`all` &sortBy=`pagetitle` &sortDir=`ASC` &paginate=`0` &paginateAlwaysShowLinks=`0` &filter=`menslist,[*storetitle*],7`!]


    I changed it to this:
    [!Ditto? &documents=`[[Ditto? &parents=`3` &display=`all` &noResults=`999999,` &filter=`menslist,[*storetitle*],7` &tpl=`@CODE:[+id+],`]]` &display=`all` &filter=`womenslist,[*storetitle*],7` &tpl=`brandsite`!]


    Unfortunately its just returning ’No Documents Found’
      • 1122
      • 209 Posts
      But it works -- maybe there are no docs with correct values in menslist. Try with swapping filters: inside clause -> outside Ditto and outside clause to inside Ditto.
        • 23183
        • 102 Posts
        OK I’ll have a play about, the value is deffinetly present as it works with my old ditto call, so I’ll have a play around with the arrangment.

        Thanks!
          • 4172
          • 5,888 Posts
          I think what you need are two inner-Ditto-calls. They get all ids you need. May be some of these are double. But this doesn’t matter. the outer Ditto-call generates a mysql-query with ’id IN (12,15,46,78,46,78,15)’ or something like that. As result ditto gets each found ressource only once.
          Try:

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

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 23183
            • 102 Posts
            Thanks for that Bruno, again unfortunately just keep returning ’No Documents found’

            EDIT - Ive had a play around with the ditto call and it seem the filter will not work when used on the inner ditto calls if I change it to:

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


            It returns results where storetitle is present in menslist. But when I put the filter part of the call back into the inner ditto call it just returns ’No Documents’

            Has anyone ever got this working?
              • 1122
              • 209 Posts
              The fact that getting a set of documents limited by a number of OR clauses is so hard to implement within MODx annoyed me in a highest degree. It should also be admitted that Bruno’s idea with two inner Ditto calls is perfect -- its logic is beyond reproach. I didn’t play with it in practice so I cannot tell why it does not work.
              However, I designed simple and easy-to-imagine idea how to get documents by many conditions joined with logical OR. (Ditto’s filter throws out documents so multiple clauses in filter parameter always produce logical AND within final set that we are left with.) My idea is based on PHx -- luckily, Ditto supports it by default. Suppose that we need to get documents whose pagetitle contains word "MODx" OR menslist TV contains text "something else".
              Ditto call:
              [[Ditto? &parents=`...` &depth=`...` &display=`all` &tpl=`get-by-or-clause`]]
              

              Chunk "get-by-or-clause":
              [+phx:if=`[+pagetitle:contains=`MODx`+][+menslist:contains=`something else`+]`:is=`00`:then=``:else=`{{your-chunk-to-display-doc}}`+]
              

              We need custom PHx modifier "contains" here, but it is funny simple to implement, and, what is more important, once implemented it may be used on many occasions. New modifier should be implemented as a snippet named "phx:contains":
              <?php
              return strpos($output, $options) === FALSE ? '0' : '1';
              ?>
              

              How it works? "contains" modifier transforms placeholder into ’1’ or ’0’ depending on whether it contains requested text or not. "if" statement concatenates both transformed placeholders pagetitle and menslist -- if it appears to be "00" (neither pagetitle contains "MODx" nor menslist contains "something else") no output is produced, otherwise (at least one condition is satisfied) regular output is rendered. The idea was tested on live site.

              Happy New Year for all members of this forum!
                • 26931
                • 2,314 Posts
                However, I designed simple and easy-to-imagine idea how to get documents by many conditions joined with logical OR.
                alik (and Bruno), thanks for this smiley Happy New Year!
                  • 23183
                  • 102 Posts
                  Thanks for that alik, I am unfamiliar with PHx, I have just installed it and followed your instructions. There are a few things I am unsure of.. What chunk should I use here:

                  else=`{{your-chunk-to-display-doc}}

                  Also where should I call the template to display ditto results I normally used in my ditto call {{brandsite}}

                  I am trying it with this ditto call:
                  [!Ditto? &startID=`3` &tpl=`get-by-or-clause` &display=`all` &sortBy=`pagetitle` &sortDir=`ASC` &paginate=`0` &paginateAlwaysShowLinks=`0`!]


                  And this for Chunk "get-by-or-clause":

                  [+phx:if=`[+womenslist:contains=`[*storetitle*]`+][+menslist:contains=`[*storetitle*]`+]`:is=`00`:then=``:else=`{{brandsite}}`+]


                  But get no results..

                  Sorry Im a bit of a novice!
                    • 4172
                    • 5,888 Posts
                    you do not need to install phx for that, because Ditto brings its own phx.

                    What chunk should I use here:

                    else=`{{your-chunk-to-display-doc}}`

                    Also where should I call the template to display ditto results I normally used in my ditto call {{brandsite}}

                    you can do

                    else=`{{brandsite}}` 

                    or you can put your content of brandsite here:

                    else=`put your normal chunk-content here` 





                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 23183
                      • 102 Posts
                      Thanks Bruno, I was trying using {{brandsite}}

                      My code for the brandsite chunk is
                      <li>> <a href="[~[+id+]~]" title="[+pagetitle+]">[+introtext+]</a></li>


                      What is displayed is a list, but the [+introtext+] is not visible so I just see

                      >
                      >
                      >
                      >
                      etc..

                      When I check the source code the link data is there. Am I unable to [+introtext+] with PHx?

                      Unfortunately what I also notice in the source code is that it is still only listing those where [*storetitle*] appears in ’menslist’ and none of the documents that have [*storetitle*] in ’womenslist’ sad