In the admin we have an option to set a sorting for children using one field only. I have a problem with children getting sorted randomly when using a date field that is the same for multiple children.
Usually we would sort by date and by ID or title, but we are only allowed to specify one field at a time.
The problem with this is that once you edit one of those children, the sorting is randomly changed (actually everytime you edit a children) That's not really nice and very confusing.
I had to use a dirty hook to change the children sorting one parent manually.
$this->addHookBefore("ProcessPageList::find", $this, "sortingChildren");
public function sortingChildren(HookEvent $event){
$sel = $event->arguments("selectorString");
$page = $event->arguments("page");
if($page->template == "news-category"){
$event->setArgument("selectorString", $sel . ",sort=-datetime, sort=-id");
}
}
Maybe there's already a way I don't know or a module? But then I think this should be in core of course and not a module.
Thanks.