-
- 64 Posts
Can someone help me out here. i am sure i am overlooking something very obvious, but i am trying to do a filter on a TV date field in the ditto call and cannot get it to work right. i want all docs that have an artcle_date (tvarticle_date to ditto) that are greater than now() to appear in this particular section - but continue to get no results. here is the call:
[!Ditto? &display=`all` &tpl=`article_dittoTpl` &dateSource=`tvarticle_date` &dateFormat=`%A %B %d, %Y %r` &filter=`tvarticle_date, UNIX_TIMESTAMP(), 4` &sortBy=`tvarticle_date` &sortDir=`desc` &debug=`1`!]
I have tried the non-UNIX timestamp (CURRENT_TIMESTAMP()) as well and still get no results.
thanks in advance for any help on this.
-
- 64 Posts
they are mysql syntax. i was thinking it wanted that for the sql statement. however, i did also try php syntax and could not get date() or time() to work either.
-
- 2,542 Posts
Hi,
php functions cannot be used as snippet params.
Create a new snippet with this code for instance
return time();
and then use it within your ditto call.
To embed a snippet inside another one you must use this syntax
[!Ditto? &filter=`tvarticle_date,[[myTimeSnippet]],3` => which means in ditto language Remove all documents from results where tvarticle_date is less than now.
:-)
-
- 64 Posts
ah yeah. thanks for the BGO. it works perfectly now.
thanks all.
-
- 64 Posts
on a somewhat related note, if i wanted to add a default date to this TV (so a date is submitted even if the user does not actually select a date), can I use @EVAL return time() as the expression in the Default value of the TV? I am using this right now and it is not writing a value to the database. It may be that ’@EVAL return time()’ produces a UNIXTIME and I think the TV dates are saved to mysql in non-UNIX time format. do i need to be formatting the ’time()’ value to a non-UNIX date format for the default value?
-
- 3,250 Posts
The default value will be executed when the TV is loaded, not when saved. Thus, the default value would be the current time the tv is loaded.
-
- 118 Posts
I was wondering on this point actually. I hoped the @EVAL thing would work to set the default date TV value to the current date but realised this probably wouldn’t since the field is handled by Tigra so isn’t an actual form field. Anyone know a quick way round this?