Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions

Nesting an IF in a control


Reply

3 Posts   1084 Views

Avatar
ssssteve

22 February 2009 at 1:10pm Community Member, 4 Posts

Is it possible to use a conditional if to check a date, such as:

<% control Children %>
<% if EventDate > Now %>
<li>$Title</li>
<% end_if %>
<% end_control %>

Embargo/Expiry doesn't seem to limit my list of events (even logged out), so I need to filter them another way.

Avatar
Willr

23 February 2009 at 2:07pm Forum Moderator, 5511 Posts

the template parser is basic, you can't do comparisons between 2 variables. You will have to add a function to your Event then check on that

function ShowEvent() {
return ($this->EventDate > date('Y-m-d')) ? true : false;
}

then in your template use <% if ShowEvent %>

Avatar
ssssteve

23 February 2009 at 9:18pm Community Member, 4 Posts

Ta!