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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Odd problem with

Go to End

3 Posts   996 Views


Community Member, 165 Posts

19 August 2009 at 11:43am

Edited: 19/08/2009 11:44am

I hope this is the right place to post this. I'm not sure if it's a templating thing or what.


the Diary module displays the Start and End dates for every event.

I would like to make it so that if the start and end dates match, then only one date is displayed.

I have changed the template thus:
<p class="Duration">
<% if Start = End %>
<% else %>
$Start.Nice till $End.Nice
<% end_if %>
From $StartTime.Nice to $EndTime.Nice
at $Location

but it *always* goes to $Start.Nice till $End.Nice, even when I've tried changing the condition to <% if Start = Start %>

If I try to qualify the variables somewhat, by saying something like <% if Start.Nice = End.Nice %> or whatever else, I get the "unexpected '}' in template" error.

What am I doing wrong and how can I fix it?


Forum Moderator, 4102 Posts

19 August 2009 at 12:41pm

AFAIK, you can't compare variables in SS. Unless the value of Start is "Start" that check will always fail. The logic needs to be handled in your model.

<% if SameTime %>

function SameTime()
return $this->Start == $this->End;


Community Member, 165 Posts

19 August 2009 at 2:37pm

Oh, gotcha. I thought it was working on another template, but I can now see that it just *looked* like it was working.