Jump to content

Possible to sort children by multiple fields in the back end?


Recommended Posts

I have a bunch of events in the back end of a site which are sorted by date, and wondered if it's also possible to sort them by title within the date selection, for example using a "sort=date,sort=title" selector. In this way, an event called "A Day for Children" would show up before "Zero Hour" if they're on the same day.

I tried to make this change in the parent template's Family tab, under "Sort settings for children," however I don't see a way to use multiple sorting criteria. Is this possible somehow?

The site is currently running 2.8.62. Thanks!

Link to comment
Share on other sites

You could use a hook...

$wire->addHookBefore('ProcessPageList::find', function(HookEvent $event) {
	$selector = $event->arguments(0);
	/* @var Page $page */
	$page = $event->arguments(1);
	if($page->template == 'your_parent_template') {
		$selector .= ", sort=date, sort=title";
		$event->arguments(0, $selector);

...or this module: https://modules.processwire.com/modules/process-page-list-multiple-sorting/

  • Like 4
  • Thanks 1
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

  • Recently Browsing   0 members

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