Jump to:

3445 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » Assigning a Variable or Previous Elements in Control Loops

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

Page: 1
Go to End
Author Topic: 1012 Views
  • Vegas Rob
    Community Member
    5 Posts

    Assigning a Variable or Previous Elements in Control Loops Link to this post

    Hi. I'm fairly new to SilverStripe and I seem to have come across my first roadblock.

    I'm returning a DataObjectSet from a method in my controller that contains a set of school events sorted by date.

    Printing out these items via the control loop is very simple, but the layout the designers call for has the date as a heading and then all the events for that day printed beneath it.

    In other templating languages I'd normally assign a variable each iteration that contains the date of the previous event. That way I can check and see if I need to print a new header with the new date or not. Some times there is even some sort of "previous element" functionality built into the loops. Do either of these solutions, or another view based one, exist in SilverStripe?

    FYI, I've solved the issue by iterating through the object in the controller method and assigning a printHeader value to true or false for each DataObject, but I am curious if this is the "SilverStripe way" or if there is a better option I am missing.

    Thanks in advance for your time!

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.