Jump to content

Search for page id


matjazp
 Share

Recommended Posts

3 hours ago, matjazp said:

Is it possible to search for page ID in the search field (top right)?

You asked about this once before... ?

But "pages.id==1234" is a pretty naff syntax, so here's a hook that lets you match pages just by typing an ID into the admin search:

$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

  • Like 8
Link to comment
Share on other sites

7 hours ago, matjazp said:

Is it possible to search for page ID in the search field

What about Tracy's PW Info panel - finds the page and provides edit, view, and open links. Maybe you want for site editors, in which case this obviously isn't very useful, but I use this many times a day during development.

  • Like 2
Link to comment
Share on other sites

@Robin S thank you for this hook, it works like a charm. Its clear I'm in a hurry and don't have time to search the forum. It's also clear that you have much better memory than I do :-) 

@adrian thank you for the hint, currently I'm not using Tracy on this particular site and also users are editors.

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