We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 332
    • 23 Posts
    Hi, I am having a little trouble figuring out how to set this filter up properly.

    I have a ditto call that searches and returns my results correctly without the filter, but no results with it.

    [[Ditto? &tpl=`ditto-teacher-contact-info` &depth=`1` &parents=`94` &display=`all` &paginate=`0` &sortDir=`ASC` &sortBy=`pagetitle` &filter=`teacher-grade,[+pagetitle+],1` &debug=`1` &noResults=`<p>No teacher contact info found.</p>` ]]

    However, when I add the filter, I am getting a no results found.

    The teacher-grade tv is applied to documents in the ditto loop that I am searching. However, the "pagetitle" I want to compare or filter on is not the pagetitle of the ditto document loop, but the actual pagetitle of the page I am displaying these results on.

    I have done this type of filter before, and have a working model on another site, yet for some reason, it doesnt seem to work. When I replace the &filter=`teacher-grade,[+pagetitle+],1` with &filter=`teacher-grade,Grade1,1` for testing purposes, it filters by the criteria I set. So why would my template variable value, which is pulled directly from the pagetitle, not match the pagetitle in ditto’s loop?

    I hope this makes sense. If anyone is willing to log in and test, please let me know. I can provide access info.
    Thanks
    Anthony
    [email protected]
      • 33337
      • 3,975 Posts
      If you want to use the pagetitle of the page where ditto call is placed, then u need to use [*...*] format, aka template variable.
        Zaigham R - MODX Professional | Skype | Email | Twitter

        Digging the interwebs for #MODX gems and bringing it to you. modx.link
        • 332
        • 23 Posts
        Quote from: zi at Aug 25, 2009, 09:46 PM

        If you want to use the pagetitle of the page where ditto call is placed, then u need to use [*...*] format, aka template variable.

        Hi Zi, thanks for the response, I tried this, but no luck. Filter looks like:

        &filter=`teacher-grade,[*pagetitle*],1`

        and if I replace with:

        &filter=`teacher-grade,Grade1,1`

        for testing purposes it works fine. The tv values are pulled from the pagetitles using an SQL query. They should definitely match. I am really stuck here, since I have another site that works with the code above, but this one does not. Anyone have any ideas?
          • 33337
          • 3,975 Posts
          Have you tried calling the Ditt uncached? [!....!] ?
            Zaigham R - MODX Professional | Skype | Email | Twitter

            Digging the interwebs for #MODX gems and bringing it to you. modx.link
            • 16278
            • 928 Posts
            The field name shouldn’t be enclosed in anything for the filter - try

            &filter=`pagetitle,teacher-grade,1` (I think it’s that way round, as well - field,criterion,mode)

            See live example using pagetitle at http://www.pogwatch.com/ditto/ditto-filters.html
            wink KP
              • 332
              • 23 Posts
              Quote from: zi at Aug 26, 2009, 04:18 AM

              Have you tried calling the Ditt uncached? [!....!] ?

              SOLVED - the uncached call did it! Thank you so much!

              Note, I did try swapping the field and criteria, but I had it right the first time. The working filter now looks like:

              [!Ditto? &filter=`teacher-grade,[*pagetitle*],1` !]

              Thanks to everyone who replied. Hopefully it comes back to you tenfold.
              Anthony