Jump to content

Admin Search Box - Instant search - Hook


taotoo
 Share

Recommended Posts

I've appended the following line from wire\modules\Process\ProcessPageSearchLive.php:

$selectors[] = "start=$liveSearch[start], limit=$liveSearch[limit]";

Like this:

$selectors[] = "start=$liveSearch[start], limit=$liveSearch[limit], sort=template|-created";

But rather than modify the original file, is it possible to achieve the same with a hook? 

Link to comment
Share on other sites

7 hours ago, taotoo said:
sort=template|-created

That doesn't look like the correct syntax for setting multiple sorts in a selector string. I think it should be "sort=template, sort=-created"
https://processwire.com/docs/selectors/#sort

To apply it to the admin search using a hook:

$wire->addHookAfter('ProcessPageSearch::findReady', function(HookEvent $event) {
	$event->return .= ', sort=template, sort=-created';
});

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

8 hours ago, Robin S said:

That doesn't look like the correct syntax for setting multiple sorts in a selector string. I think it should be "sort=template, sort=-created"
https://processwire.com/docs/selectors/#sort

To apply it to the admin search using a hook:

$wire->addHookAfter('ProcessPageSearch::findReady', function(HookEvent $event) {
	$event->return .= ', sort=template, sort=-created';
});

 

Thank you very much Robin!

  • 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...