Krlos Posted January 10, 2022 Share Posted January 10, 2022 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 More sharing options...
Nicolas Posted January 10, 2022 Share Posted January 10, 2022 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 2 Link to comment Share on other sites More sharing options...
Zeka Posted January 10, 2022 Share Posted January 10, 2022 Hi @Krlos You can do it by hooking ProcessPageListRender::getPageLabel like here https://github.com/FlipZoomMedia/PageHitCounter/blob/master/PageHitCounter.module#L460 https://github.com/FlipZoomMedia/PageHitCounter/blob/master/PageHitCounter.module#L950 2 Link to comment Share on other sites More sharing options...
Krlos Posted January 10, 2022 Author Share Posted January 10, 2022 Hey @Nicolas and @Zeka. Thanks, I'm not php savy, but I will try those sugestions. Link to comment Share on other sites More sharing options...
Robin S Posted January 10, 2022 Share Posted January 10, 2022 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; } }); 5 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now