Is there a way (preferably in the template engine) to access the previous/next item in a DataList?
I have a Datalist, containing Worktimes, each Worktime is a has_one to a project (Project -> has_many(Worktimes))
I'd like to show in a template a list of worktimes.
If i Iterate through the worktimes
<% loop Worktimes %>$Project.Name - $Name<% end_loop %>
I get something like
MyProject1 - Something1
MyProject1 - Something2
MyProject2 - Something1
MyProject2 - Something2
But I'd like to have something like
MyProject1 - Something1
- Something2
MyProject2 - Something1
- Something2
So to speak, show the Project-Name only, if the previous Worktime is in a different Project...
My idea was something like this in the template:
<% loop Worktimes %>
<% if Previous.Project.ID != $project.ID %>
$Project.Name
<% end_if %>
$Name
<% end_loop %>
For this to work the DataList Iterator would need something like a Previous/Next implementation. Any Ideas, how to achieve this?
Thanks,
MC