Jump to content

Sort results of admin search?


johnnydoe
 Share

Recommended Posts

Hi folks,
is it possible to sort the results of the admin search in PW - in my case just by title of the page? I think by default it is sorted by it's position in the page tree? I tried to inidicate a sorting for the children of the page "Admin" > "Pages" > "Search", but without success. Also the "Page Search" module, found in the core modules doesn't seem to have a sort option for the results. Can anyone help me?

Thank you very much in advance!
 Jonas

Link to comment
Share on other sites

Thank you very much! 
This works very well for the first result page!
 
But if I click on "View > All pages", which takes me to the detailed search results page, the results are not in alphabetical order... can I hook this too? 
Off-topic question: how can I find which hook can I use where, or do I just need common sense and and maybe guessing to find the right hook? 🙂

Link to comment
Share on other sites

You have too hook the Lister:

$wire->addHookBefore('ProcessPageLister::execute', function(HookEvent $event) {
	/* @var ProcessPageLister $lister */
	$lister = $event->object;

	// I'm not sure, but the parent of the "Search Lister" has the ID 0?
	if($lister->parent->id !== 0) return;

	// Set sort
	$lister->defaultSort = 'title';
	bd("Changed Search Sort");
});

 

  • Like 1
Link to comment
Share on other sites

1 hour ago, johnnydoe said:

if I click on "View > All pages", which takes me to the detailed search results page, the results are not in alphabetical order...

IIRC this just takes you to the normal page finder, where you can click the column headers to sort. You can also add and remove columns if the one you’re looking for isn’t there by default.

  • Like 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
 Share

  • Recently Browsing   0 members

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