Jump to content

Recommended Posts

Posted

I tried to add the page id to be searchable in the admin Ajax search-field. The help message says the field has to be text-based: "Enter the names for one or more text-based fields that you want to search, separating each by a space." Is there any way to add the page id to be searchable?

  • 1 year later...
Posted

i'm at the same point as Ipa: need to add a number field to the admin live search. do I have to copy the module to the site/ folder and change it there?

 

Posted

beauty! Works perfectly well - thanks!

I got stuck in the forum search, looking for admin live search and integer values.

I cite here the code, just in case:

On 5/7/2020 at 11:56 PM, Robin S said:

 


$wire->addHookAfter('ProcessPageSearch::findReady', function(HookEvent $event) {
	$selector = $event->return;
	$q = $event->wire('input')->get('q');
	// If the admin search query is a number
	if(is_numeric($q)) {
		// Get the individual pieces of the selector
		$selector_pieces = explode(', ', $selector);
		// Modify the first piece so that it includes an ID clause in an OR-group
		$selector_pieces[0] = "({$selector_pieces[0]}), (id=$q)";
		// Replace the original selector
		$event->return = implode(', ', $selector_pieces);
	}
});

2020-05-08_095548.png.946178db80b95a8a1483960c250250ba.png

Posted

If you ask me, searching by id should be made configurable in the module settings, but solution from Robin works, of course.

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