Jump to content

Sort children by multiple fields in the admin (kinda needed really)


Soma
 Share

Recommended Posts

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.

  • Like 13
Link to comment
Share on other sites

  • 3 months later...
  • 2 years later...
55 minutes ago, LostKobrakai said:

Thanks for the info!

Yeah, I've noticed this module before but I feel the same with Soma here that this should be something that's already implemented as a core feature. The idea of scattered sorting settings between template and module config seems bit complicated in a long run.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...