The generateBreadcrumb
hook is used to manipulate the breadcrumb navigation
(from breadcrumb front end module). It passes the breadcrumb items as an array
and the front end module object as arguments and expects an array (the breadcrumb
items) as return value.
array $items
The breadcrumb navigation items.
\Contao\Modul $module
The front end module instance executing the hook.
An array containing associative array items with the following information for the breadcrumb item:
isRoot
Whether this is the root item.isActive
Whether this is an active item.href
The URL for this breadcrumb item.title
The title attribute for this breadcrumb item.link
The text for this breadcrumb item.data
Associative array containing the data of tl_page
.class
The CSS classes for this breadcrumb item.// src/EventListener/GenerateBreadcrumbListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
use Contao\Module;
#[AsHook('generateBreadcrumb')]
class GenerateBreadcrumbListener
{
public function __invoke(array $items, Module $module): array
{
// Modify $items …
return $items;
}
}