Quote from: Mark at Jul 04, 2007, 10:22 PM
Ditto supports the @EVAL binding to evaluate php expressions in filter clauses. Thus, @EVAL time(); is the correct syntax to get the current unix timestamp ala http://modxcms.com/eval-binding.html. Here is a working example which will retrieve all documents in the last year.
[!Ditto?parents=`2`&debug=`1`&display=`all`&filter=`createdon,@EVAL return strtotime('-1 year');,6`!]
Hi, I wonder if this is correct ... The &filter EXCLUDES documents from the results. So, if you filter documents created on a date greater or equal (6) to "now minus one year", you EXCLUDE all the docs from last year, not include.
Also, I wonder why you first say [tt]@EVAL time();[/tt] is correct, but in your example you write [tt]@EVAL return strtotime();[/tt] (the difference is the "return").
I ask, because I am having massive problems with date filtering.
I also have a TV with unixtimestamp. Sorting works fine, but filtering doesn’t work at all. i have [tt]&filter=`VAStart,@EVAL return time();,3`[/tt] to filter out all events from the past. I get all docs. And, if i use 6 instead of 3, I also get all the docs.
Debugging shows me that the filter is recognized corretly and that the values of the VAStart TV are correct too. I don’t know what the problem is.
BTW: I used Ditto 2.0.2, but I have just upgraded to 2.1. But I still run into the same problems.
Thanks
Martin