Jump to:

10987 Posts in 2724 Topics by 1817 members

All other Modules

SilverStripe Forums » All other Modules » Odd problem with DiaryHolder.ss

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 753 Views
  • _Vince
    Avatar
    Community Member
    161 Posts

    Odd problem with DiaryHolder.ss Link to this post

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

    Anyway...

    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 %>
                                  $Start
                                  <% else %>
                                  $Start.Nice till $End.Nice
                                  <% end_if %>
                                  <br/>
                                  From $StartTime.Nice to $EndTime.Nice
                                  <br/>
                                  at $Location
                               </p>
    .
    .
    .

    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?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Odd problem with DiaryHolder.ss Link to this post

    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;
    }

  • _Vince
    Avatar
    Community Member
    161 Posts

    Re: Odd problem with DiaryHolder.ss Link to this post

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

    Thanks!

    753 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.