I have some event resources with a template variable for the date, and I want to display only the ones that are still in the future. After struggling a lot, being a newbie, I have found a solution. Here it is in case any one else is struggling likewise.
I suspect it’s not very efficient and would appeciate any comments anyone has.
The template variable ’eventDate’ is set up with:
Input Type: Date
Input Option Values: <empty>
Default Value: <empty>
Output Type: String
String Format: None
The template variable ’now’ is set up with:
Input Type: Date
Input Option Values: <empty>
Default Value: @EVAL return time();
Output Type: String
String Format: None
The call to ’getResources’ works the usual way:
[[!getResources?
&parents=`7`
&sortbyTV=`eventDate`
&sortdirTV=`ASC`
&includeTVs=`1`
&processTVs=`1`
&tpl=`futureEventChunk`
]]
The code for ’futureEventChunk’ is:
[[!If?
&subject=`[[+tv.eventDate]]`
&operator=`>`
&operand=`[[*now ]]`
&then=` ...... output the info ..... `
]]
Notice that in the chunk, it’s +tv.eventDate but it’s *now. I spent a lot of time changing the + and * and putting tv. in and out. One day I hope to understand why this is the correct combination.