Hello everyone,
I have an events section in my website, every event is a child to this section, I want two different sorts, one sorted based on date, one sorted based on date > CURDATE() with interval of 7 days and if possible gets a sort of random as well (which would be something like current event) . this is what I did so far but doesnt work properly:
class:
<?php
class RadarHolder extends Page {
private static $allowed_children = array (
'RadarEntry'
);
}
class RadarHolder_Controller extends Page_Controller {
public function SortedChildren(){
$children = $this->Children();
if( !$children )
return null;
$children->sort('Date');
return $children;
}
public function CurrentEvent($count = 1){
return RadarEntry::get()
->sort('Date > CURDATE(), INTERVAL 7 DAY')
->limit($count);
}
}
template:
<% if CurrentEvent %>
<% control CurrentEvent %>
...
<% end_control %>
<% end_if %>
.
.
<% loop SortedChildren %>
...
<% end_loop %>
What should I do to make it work?
Thanks in advance