Jump to content

Display additional field next to title on tree list.


lenoir
 Share

Recommended Posts

I need to display a datetime field next to the title of the page on the tree list. I've used the following code in the ready.php file previously, but it's not working anymore. Also, I'm looking at displaying the date on the tree, not in the search. 

Am I doing something wrong? Unfortunately I'm not familiar with hooks…

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

        $page = $event->arguments(0);
        
        if($page->template == 'event') {
            
            $suffix = $page->datum;

            $event->return .= ", {$suffix}";

        }

    });
});

 

Link to comment
Share on other sites

It should be enough to hook "ProcessPageListRender::getPageLabel", no secondary hook necessary.

$wire->addHookAfter('ProcessPageListRender::getPageLabel', function(HookEvent $event) {
    $page = $event->arguments(0);
    
	if($page->template == 'event') {
		$suffix = $page->datum;
	    $event->return .= ", {$suffix}";
	}
});

 

Link to comment
Share on other sites

1 hour ago, ngrmm said:

@lenoir you could also use the builtin option in the backend here:
setup > templates > your-template > advanced >  List of fields to display in the admin Page List

Ooh… i didn't know about these settings! Thanks a lot, that's exactly what I needed…

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