Jump to content

Display multiple fields in the page search (backend)


lenoir
 Share

Recommended Posts

Is it possible to display 2 fields in the page search? 

I got a series of pages about trees with the same name (as a page title) but different locations.

I wish I could display something like {title}, {location}

Thanks.

Link to comment
Share on other sites

I'm talking about ProcessPageSearch. Concrete case: the user searches a particular page in the search field top right corner. If they type the name of a tree, there's a bunch of pages that will display with that particular tree. I would need it to display a second field with the location. So they see in the result "tree, location".

I'm also using ProcessPageList (which is perfect for displaying the pages in the tree (this time I'm talking about the tree of pages in the backend ?). But this is a different need.

Lister might be an alternative solution, actually ?

  • Like 1
Link to comment
Share on other sites

I did something like you want. Add this hook to ready.php:

$wire->addHookBefore('ProcessPageSearchLive::execute', function(HookEvent $event) {
	$event->wire()->addHookAfter('FieldtypePageTitle::wakeupValue', function(HookEvent $event) {

		$page = $event->arguments(0);
		
		// specify your template
		if($page->template == 'tool') {

      		// get the fields you like
			$prefix = $page->pre;
			$suffix = $page->suf;

			// add your data to the list
			$event->return .= " | {$prefix} {$suffix}";

		}

	});
});

 

  • Like 3
Link to comment
Share on other sites

13 minutes ago, Klenkes said:

I did something like you want. Add this hook to ready.php:

$wire->addHookBefore('ProcessPageSearchLive::execute', function(HookEvent $event) {
	$event->wire()->addHookAfter('FieldtypePageTitle::wakeupValue', function(HookEvent $event) {

		$page = $event->arguments(0);
		
		// specify your temlate
		if($page->template == 'tool') {

      		// get the fields you like
			$prefix = $page->pre;
			$suffix = $page->suf;

			// add your data to the list
			$event->return .= " | {$prefix} {$suffix}";

		}

	});
});

 

Wow, thanks! That's exactly it. ?

  • 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

×
×
  • Create New...