Ditto Date Filter

The DateFilter extender (&extenders=`dateFilter`) enables you to filter Ditto listing by year, month and day in a specified document field or template variable. The Ditto site describes it as a "filtering companion to Reflect or other date based filtering", which I think means you can use a Reflect archive listing to feed back the date parameters. Maybe I'll go into Reflect later. Meanwhile, DateFilter is quite easy to use directly with Ditto.

The &dateFilterSource parameter can be `get`, `params` or the name of a request variable. The default is `get` (obtain filter data from URL query string). Using `params`, you can set the filter in the Ditto call, e.g. &dateFilterSource=`params` &year=`2007`. Using the other option, a request variable passed in the URL query string or the POST data from a form, the date is given in a single string that can be interpreted by the PHP strtotime() function and broken down into a specific year, month and day, e.g. &dateFilterSource=`cdate` and www.example.com/blogs.html?cdate=aug+4+2007 (substituting plus signs for spaces as it's in a URL).

The &dateSource parameter determines which field or template variable is used for comparison in filtering, as well as being the source for the [+date+] placeholder.

The &year, &month (numerical value) and &day parameters set the date to filter on in a hierarchical way - a month without a year, or a day without a month, will be ignored.

There is also a &dateFilterDefault parameter, which can be set to `0` (off), `1` (current year), `2` (current month) or `3` (current day).

The extender sets the placeholders [+year+] [+month+] and [+day+], which can be used in headings on the listing page.


Show me items for: 2006 | August 2005 | 12 December 2007


Static sample:

Items for June 2006

(Heading code: <h4>Items for [+day+] [+month+] [+year+]</h4>

[[Ditto? &parents=`6` &extenders=`dateFilter` &dateFilterSource=`params` &year=`2006` &month=`6` &dateSource=`pkDate` &dateFormat=`%d %b %Y` ]]

Nulla euismod, ITEM 125 arcu a pellentesque mattis,

by Anon on 01 Jun 2006
Donec orci sem, molestie ut, vestibulum quis, rutrum quis, nulla. Duis elementum mollis urna

Donec molestie, ITEM 171 ligula at convallis interdum,

by Anon on 28 Jun 2006
Sed suscipit luctus arcu. Phasellus tortor