Hi all,
I'm using the GroupedBy method in the templates to group a set of data by a Y-m-d formatted date. All works fine, except that I'd like to further format the index value. For example, here's how I'm using it currently:
<% loop GroupedData.GroupedBy(Day) %>
<h2>$Day</h2>
<% loop Children %>
...
<% end_loop %>
<% end_loop %>
Where (Day) relates to the following function:
public function getDay() {
return date('Y-m-d',strtotime($this->ActivityStartDateTime));
}
Obviously the title then renders as a Y-m-d date (i.e. 2013-06-26), but what I'd like to do is to manipulate the $Day index value, so for example, what I'm looking to achieve is something similar to:
<% loop GroupedData.GroupedBy(Day) %>
<h2>
<span class="calendar-icon">
<span class="month">$Day.FormatMonth</span>
<span class="day">$Day.FormatDay</span>
</span>
$Day
</h2>
<% loop Children %>
...
<% end_loop %>
<% end_loop %>
... and use a function somewhere to format the $Day value:
public function FormatMonth() {
return date('m',strtotime($this));
}
public function FormatDay() {
return date('d',strtotime($this));
}
If there's a way to achieve the above then I'd be grateful for some pointers from someone.
Cheers,
Alex