We are using sites for different content for our page, where we set the active site by having different URLs.
Now I’m trying to change some menu items titles of the RainLab.Pages plugin by using pages.menuitem.resolveItem
iwth no success:
public function boot()
{
Event::listen('pages.menuitem.resolveItem', function($type, $item, $url, $theme) {
if ($item->code !== 'menu_add_year') {
return;
}
$site = \Site::getActiveSite();
$items = [];
$item = [
'title' => $item->title . ' ' . $site->name,
'url' => $url,
'mtime' => time(),
'isActive' => Url::current() === $url,
'isChildActive' => false,
];
return $item;
});
}
How to override menu titles with the item code menu_add_year
correctly?