Closed mccombs closed 7 years ago
Hello Adam. Please get in touch with me. You've got my contact info.
I think maybe @brandonkelly copied the wrong code sample, it should be:
// New:
use craft\events\RegisterCpNavItemsEvent;
use craft\web\twig\variables\Cp;
use yii\base\Event;
Event::on(Cp::class, Cp::EVENT_REGISTER_CP_NAV_ITEMS, function(RegisterCpNavItemsEvent $event) {
if (\Craft::$app->user->identity->admin) {
$event->navItems['foo'] = [
'label' => \Craft::t('myplugin', 'Utils'),
'url' => 'utils'
];
}
});
Still scratching my head on this. I took a look at the Redirect Plugin and I thought it was as simple as
use craft\events\RegisterCpNavItemsEvent;
andpublic function getCpNavItem() { return [ 'url'=> 'newsblast', 'label'=>Craft::t('newsblast', 'Newsblast'), 'icon' => 'icon' ]; }
but Brandon says you have to run this through a cache event? https://github.com/craftcms/cms/issues/1838Could the generator include an option for a control panel nav item?