The getUserNavigation
hook allows to manipulate the back end user navigation.
It passes the back end modules and a flag wether to show collapsed navigation
items. Expects the array of modules as return value.
array $modules
The compiled list of back end modules.
boolean $showAll
Wether to show all modules even if the group is collapsed.
Add your custom modules to the list and return the array of back end modules.
// src/EventListener/GetUserNavigationListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
#[AsHook('getUserNavigation')]
class GetUserNavigationListener
{
public function __invoke(array $modules, bool $showAll): array
{
// Add custom navigation item to the Contao website
$modules['system']['modules']['contao'] = [
'label' => 'Contao homepage',
'title' => 'Visit the Contao CMS website',
'class' => 'navigation contao',
'href' => 'https://contao.org/en/',
];
return $modules;
}
}