I’m following the Panel menu guide on how to add custom menu items alongside the default ones in Kirby 4.
Everything is working except the ‘site’ menu item is now not highlighted when selected and I am not sure what I am doing wrong?
The menu items ‘users’ and ‘system’ is highlighted correctly when I click on them.
My code looks as following:
'panel' => [
'menu' => [
'site' => [
'current' => function (): bool {
// the links of all your custom menu entries
$links = ['pages/work', 'pages/share'];
$path = Kirby\Cms\App::instance()->request()->path();
return A::every($links, fn ($link) => Str::contains($path, $link));
}
],
'work' => [
'icon' => 'book',
'label' => 'Work',
'link' => 'pages/work',
'current' => function (string $current): bool {
$path = Kirby\Cms\App::instance()->request()->path()->toString();
return Str::contains($path, 'pages/work');
}
],
'share' => [
'icon' => 'plane',
'label' => 'Share',
'link' => 'pages/share',
'current' => function (string $current): bool {
$path = Kirby\Cms\App::instance()->request()->path()->toString();
return Str::contains($path, 'pages/share');
}
],
'-',
'users',
'system'
]
I did notice that the docs was missing a ‘;’ after the return statement in the current block but that made no difference.
'current' => function (): bool {
// the links of all your custom menu entries
$links = ['pages/work', 'pages/share'];
$path = Kirby\Cms\App::instance()->request()->path();
return A::every($links, fn ($link) => Str::contains($path, $link)); // ';' was missing
}
Any suggestions or hints would be greatly appreciated.
Kirby: 4.1.0
PHP: 8.3.3
Browser: Safari 17.3
OS: Mac 14.3