Jump to content

Recommended Posts

Posted

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:

labels.jpg.6ad3431c3130560ee31bb78e4003358f.jpg

That label is page reference.

Thanks in advance.

Posted

Hi,

Have you had a look at one/some of these PageList modules ?

There's also many discussions in the forum related to your query :

 

You may also want to have a look into the ProcessWire hooks system.

 

Hope this helps

  • Like 2
Posted

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;
	}
});

2022-01-11_100531.png.249adc128536350e0236656a6c6e3e9d.png

  • Like 5
  • Thanks 2

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