Jump to content
matjazp

Search for page id

Recommended Posts

Is it possible to search for page ID in the search field (top right)? It looks like it only search for title (and other fields if configured) but not by ID... 

Share this post


Link to post
Share on other sites
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 7

Share this post


Link to post
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 1

Share this post


Link to post
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.

Share this post


Link to post
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...