2

I‘m a newbie and I’m learning to create simple portfolio-type sites using Craft CMS. I‘d like to remove the Plugin Store from the admin panel in the Production Environment because basically, I don't need to install plugins and the product environment plugin store is just read-only mode. I have checked the official documentation and the community without any information about it.

Colt
  • 23
  • 3

3 Answers3

2

You can use an event hook for the event Cp::EVENT_REGISTER_CP_NAV_ITEMS to modify the Control Panel navigation – see Control Panel Sections in the documentation. To determine if the site is in devMode, you can use the config service. Here's a little module that removes the plugin store from the navigation elements unless the site is in dev mode:

<?php

namespace modules\Site;

use Craft; use craft\events\RegisterCpNavItemsEvent; use craft\web\twig\variables\Cp; use yii\base\Event;

class SiteModule extends \yii\base\Module { public function init() { Event::on( Cp::class, Cp::EVENT_REGISTER_CP_NAV_ITEMS, function(RegisterCpNavItemsEvent $event) { if (Craft::$app->config->general->devMode) return; $pluginStoreIndex = array_search( 'plugin-store', array_column($event->navItems, 'url') ); if ($pluginStoreIndex === false) return; unset($event->navItems[$pluginStoreIndex]); } );

    parent::init();
}

}

To make this work, you need to put that code into a site module and add it to the bootstrap section in the app.php config. See How to Build a Module for details.

MoritzLost
  • 11,215
  • 5
  • 22
2

I must say that I don't understand the rationale behind hiding the Settings in production but not the Plugin Store.

The only action you can really do in production is upgrade to a Pro licence if you don't have one already, so this might be the reason but I think the link at the bottom of the page there if you need it.

For me the 'allowAdminChanges' => false should also hide the Plugin Store or another trigger like 'showPluginStore' should be added.

fdelaneau
  • 123
  • 6
1

You can also use the CP Nav plugin

psithu
  • 61
  • 4