We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22797
    • 134 Posts
    Correct me if I’m wrong, but as far as I can tell, ditto can’t fetch documents according to the template the document uses. In Ditto you can say &parents and &documents, but you can’t say &templates. Is this accurate?

    In the system I’m using, I’m treating templates as if they were database tables, in a way, so it would be useful to be able to limit the scope of the search to certain "tables" (templates). Let me know if this is already possible using some other method. If not, I’ll add it to my wish list.
      • 7231
      • 4,205 Posts
      I think that HyperFlexSearch allows you to limit the scope by template. They have a number of filters that look cool, but I have not yet used it so I can’t confirm.

        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 11975
        • 2,542 Posts
        Hi,

        use the &filter param
        &filter=`template,mytpl,1`

        :-)

          Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
          • 7231
          • 4,205 Posts
          Oh, that is how it works.

          More on the filter parameter here:
          http://ditto.modxcms.com/tutorials/basic_filtering.html
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 33337
            • 3,975 Posts
            Man, its a gold mine... u just need to dig a bit wink
              Zaigham R - MODX Professional | Skype | Email | Twitter

              Digging the interwebs for #MODX gems and bringing it to you. modx.link
              • 22797
              • 134 Posts
              Quote from: heliotrope at Nov 16, 2007, 03:50 PM

              Hi,

              use the &filter param
              &filter=`template,mytpl,1`

              :-)



              You’re right that this will work if I need to limit the query to one template. If I add another filter to increase the scope of the query to include a total of 2 or more templates, though, the &filter doesn’t seem to be sophisticated enough to do what I want it to do. It excludes all documents, because each document has only one template. The &filter query takes all filters into account, returning no results.

              I’ve been trying to get the &where parameter to do the filtering for me, but I may be misunderstanding something about that parameter, because it’s not doing what I’m telling it to do.

              If I write &where=`template=7` it gives me a fatal MODx parse error. If I write &where=`template = 7` it doesn’t give me the fatal error, but it also doesn’t filter anything. If I write &where=`template = 7 and template = 5` it doesn’t filter either. I’m sure I’m missing something simple. Any advice?

              In the end, though, it would be easiest to just do this: &templates=`5,7`. This syntax would be used instead of &parents or &documents
                • 11975
                • 2,542 Posts
                Hi,


                You’re right that this will work if I need to limit the query to one template. If I add another filter to increase the scope of the query to include a total of 2 or more templates, though, the &filter doesn’t seem to be sophisticated enough to do what I want it to do. It excludes all documents, because each document has only one template. The &filter query takes all filters into account, returning no results.

                You can easily write your own filter without hacking the ditto code.
                Have a look at the sample extenders in the ditto folder.
                You could also use a filter I have written for tvExplorer.

                What you need is something similar to onlyTags mode.

                :-)

                EDIT: try with &tagData=`template` &tagMode=`onlyTags` &tags=`tpl1,tpl2` &extenders=`tagging`
                If you don’t want to write code or use extenders

                :-)

                EDIT2: If you want to pass several values in filter change the localFilterDelimiter to =`:` that way you can use a comma to separate each template value.
                AnyWay I guess the basic filter included in Ditto will not be enough but you can change my own code (tveFilter.extenders) to suit your need.
                  Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                  • 22797
                  • 134 Posts
                  Well, how about that. The tagging method works with the template field, which effectively solves my problem. I was under the (mistaken) impression that the tagging method worked only with template variables. I’m happy to learn that it works with document fields as well.

                  Thanks!
                    • 18397
                    • 3,250 Posts
                    The tagging extender, and all extender based filters (ex: dateFilter), have access to the entire document object.
                      • 7231
                      • 4,205 Posts
                      The tagging extender, and all extender based filters (ex: dateFilter), have access to the entire document object.
                      That is so cool, this resolve an issue I have as well.
                        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                        Something is happening here, but you don't know what it is.
                        Do you, Mr. Jones? - [bob dylan]