Jump to content

Custom page list label


Recommended Posts

Hi, I need to place an icon or label in some pages in my tree.

I found that page list label allows to change the format for the label like this:

{categories.title} {title}

How can turn that into this:


That label is page reference.

Thanks in advance.

Link to comment
Share on other sites

Assumes "categories" is a multiple Page Reference field and that you have a hex colour defined on each category page:

$wire->addHookAfter('ProcessPageListRender::getPageLabel', function(HookEvent $event) {
	$page = $event->arguments(0);
	if($page->template == 'accommodation') {
		$out = '';
		foreach($page->categories as $category) {
			$out .= "<span class='uk-label' style='background-color:$category->hex_colour'>$category->title</span> ";
		$out .= $page->title;
		$event->return = $out;


  • Like 5
  • Thanks 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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...