We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5628
    • 44 Posts
    Hey
    Wanting to filter a Ditto call by a particular TV associated with each document.
    Scoured google, the forums and the documentation but finding it difficult to find a solution.
    What says you?

    Cole
    huh
      • 4310
      • 2,310 Posts
      As an example here is one I have used...
      &filter=`EventDate,@EVAL return time();,3`

      EventDate is the name a unixtime widget TV and the @EVAL part of the filter returns the latest 3 events for Ditto to summarize.
        • 5628
        • 44 Posts
        Just to follow up on this, don’t know if my widget isn’t working but having set up a date-type TV using the unixtime widget my TV values are still being stored in the mod-x database as MySQL date strings.
        Would I be right in assuming then that widgets only affect the display of the TV and not how the value is stored in the modx database.
        For example, 4th February is stored as 04-02-2008 00:00:00 rather than 1202083200.
        If so, if I want to filter a Ditto call using @EVAL on this TV then I would have to use a suitably formatted date() function rather than time().
        For example,
        &filter=`EventDate,@EVAL return date('d-m-Y');,4`
        


        Is this right (well, it works on my system) or is my widget bust?

        Cole
          • 4310
          • 2,310 Posts
          I did this a while ago so am a little hazy!
          The object was to just use the tv as a filtering mechanism, in this case to limit Ditto to the next 3 future events.
          I think I tried the date() function, but had some issues with the formatting.
          You’re right about the widget not saving to the database as a unixtime, in my case that didn’t matter.
          At the end of the day it worked so I didn’t question it too deeply!

          David
            • 18397
            • 3,250 Posts
            Ditto understands the display widget when filtering. Thus, so long as the widget is properly set, Ditto will be able to filter by unixtime. The only reason filtering by date(’d-m-Y’) instead of unixtime would work is if the widget is not properly set or you are using a very old version of Ditto (1.x).
              • 5628
              • 44 Posts
              Quote from: Mark at Feb 13, 2008, 06:16 PM

              Ditto understands the display widget when filtering. Thus, so long as the widget is properly set, Ditto will be able to filter by unixtime. The only reason filtering by date(’d-m-Y’) instead of unixtime would work is if the widget is not properly set or you are using a very old version of Ditto (1.x).

              Hi Mark
              Using Ditto 2.02 and have unixtime widget alloted to relevant TV - what do you mean by ’properly set’?
              date() solution seems to be working fine but curious now as to why unixtime isn’t being interpreted on this TV.

              Cole
                • 18397
                • 3,250 Posts
                Could you provide the debug output of your call?
                  • 21800
                  • 174 Posts
                  Hi,
                  date filtering is a problem for me.

                  Using this call (which works fine with ditto 2.0.3)
                  [[Ditto? &parents=`83` &filter=`kategorie,Krebs,7` &tpl=`ditto_events` &paginate=`1` &display=`5` &tagData=`tags` &tagDelimiter=`, ` &sortBy=`StartTime` &dateSource=`StartTime` &dateFormat=`%c` &tagDocumentID=`89`]]

                  I have now to suppress the output of events older than the current month. but how to manage ?
                  StartTime (also EndTime are TVs set to date / unixtime.

                  Could i set a second filter ? if yes how? or is there another possibility?
                    • 7231
                    • 4,205 Posts
                    Yes you can set a second filter set. Check out this page for an example:

                    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]