Im trying to sort all my product pages across the site by their given date descending. But also group them by their grandparents title (as this is the product category) and finally if possible any that do not have a date (ProductReleaseDate) to be listed first before everything.
I have this function in my page controller that grabs all the product pages:
function ProductPages()
{
$productPages = ProductPage::get();
return $productPages ? $productPages : false;
}
Then in my template:
<% loop $ProductPages.Sort(ProductReleaseDate, DESC) %>
$Title
<% end_loop %>
This displays all my product pages titles in descending order by the ProductReleaseDate they have been given. They now need grouping..
I've been searching hard and can't find the right documentation or examples to get this right. Perhaps I need groupBy? I'm not sure if it needs to be in the controller or the template.. this may help but I need help. Many thanks.
http://docs.silverstripe.org/en/developer_guides/model/how_tos/grouping_dataobject_sets/