Search the blog

You can choose what fields are displayed when a page is shown in the site tree. By what if you want to do something more complex? The code below shows how you can hook into a page before it’s rendered in the site tree.

In this example, for the template foo-bar, we append a unique ID to the end.

\ProcessWire\wire()->addHookAfter('ProcessPageListRender::getPageLabel', function($event) {

    $page = $event->arguments('page');

    if ($page->template->name == 'foo-bar') {

        $event->return .= ', ' . uniqid();

    }

});
Tim Bennett is a Leeds-based web designer from Yorkshire. He has a First Class Honours degree in Computing from Leeds Metropolitan University and currently runs his own one-man web design company, Texelate.