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   1091 Views

Avatar
ssssteve

Community Member, 4 Posts

22 February 2009 at 1:10pm

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

Forum Moderator, 5513 Posts

23 February 2009 at 2:07pm

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

Community Member, 4 Posts

23 February 2009 at 9:18pm

Ta!