Nexus for WinterCMS can be found here
Implements backend sidemenu, custom menus, menu sorting
- clone the repo to folder
plugins/xitara/nexus
- cd to
plugins/xitara/nexus
- run
yarn
to fetch all the dependencies
start
- start the dev servercleanup
- remove compiled data, node_modules, vendor, etc. don't delete any sourceswatch
- start webpack --watchdwatch
- start webpack --watch --mode developmentbuild
- build the complete app including copying static contentdbuild
- build the complete app including copying static content with --mode developmentzip
- zips a package with only needed files without overheaddeploy
- deploys a package with only needed files without overhead in a folder without zippingftp
- uploads a minimizes package to a configured server (needs lftp)analyze
- analyze your production bundlelint-code
- run an ESLint checklint-style
- run a Stylelint checkcheck-eslint-config
- check if ESLint config contains any rules that are unnecessary or conflict with Prettiercheck-stylelint-config
- check if Stylelint config contains any rules that are unnecessary or conflict with Prettier
use App;
use Backend;
use BackendMenu;
use Event;
use System\Classes\PluginBase;
use System\Classes\PluginManager;
/**
* Check if we are currently in backend module.
*/
if (!App::runningInBackend()) {
return;
}
/**
* get sidemenu if nexus-plugin is loaded
*/
if (PluginManager::instance()->exists('Xitara.Nexus') === true) {
Event::listen('backend.page.beforeDisplay', function ($controller, $action, $params) {
$namespace = (new \ReflectionObject($controller))->getNamespaceName();
if ($namespace == '[VENDOR]\[PLUGIN]\Controllers') {
\Xitara\Nexus\Plugin::getSideMenu('[VENDOR].[PLUGIN]', '[PLUGIN-SLUG]');
}
});
}
public function register()
{
if (PluginManager::instance()->exists('Xitara.Nexus') === true) {
BackendMenu::registerContextSidenavPartial(
'[VENDOR].[PLUGIN]',
'[PLUGIN-SLUG]',
'$/xitara/nexus/partials/_sidebar.htm'
);
}
// ...
}
Extend your navigation label with ::hidden to hide it from top navigation
public function registerNavigation()
{
$label = '[VENDOR-SLUG].[PLUGIN-SLUG]::lang.plugin.name';
if (PluginManager::instance()->exists('Xitara.Nexus') === true) {
$label .= '::hidden';
}
return [
'[VENDOR-SLUG]' => [
'label' => $label,
'url' => Backend::url('[VENDOR-SLUG]/[PLUGIN-SLUG]/[CONTROLLER-SLUG]'),
'icon' => 'icon-leaf',
'permissions' => ['[VENDOR-SLUG].[PLUGIN-SLUG].*'],
'order' => 500,
],
];
}
public static function injectSideMenu()
{
$i = 0;
return [
'[PLUGIN-SLUG].[CONTROLLER-SLUG]' => [
'label' => '[VENDOR-SLUG].[PLUGIN-SLUG]::lang.submenu.[CONTROLLER-SLUG]',
'url' => Backend::url('[VENDOR-SLUG]/[PLUGIN-SLUG]/[CONTROLLER-SLUG]'),
'icon' => 'icon-archive',
'permissions' => ['[VENDOR-SLUG].[PLUGIN-SLUG].*'],
'attributes' => [ // can be extendet if you need, no limitations
'group' => '[VENDOR-SLUG].[PLUGIN-SLUG]::lang.submenu.label',
'level' => 1, // optional, default is level 0. adds css-class level-X to li
],
'order' => Nexus::getMenuOrder('[VENDOR-SLUG].[PLUGIN-SLUG]') $i ,
],
...
];
}
public function __construct()
{
parent::__construct();
BackendMenu::setContext('[VENDOR].[PLUGIN]', '[PLUGIN-SLUG]', 'nexus.[CONTROLLER-SLUG]');
}
[VENDOR-SLUG].[PLUGIN-SLUG]::lang.submenu.label
is the heading of your menu items[VENDOR-SLUG].[PLUGIN-SLUG]::lang.submenu.[CONTROLLER]
is the your menu item
On top of Plugin.php
:
use Xitara\Nexus\Models\Setting;
and as registration method
public function registerSettings()
{
if (($category = Settings::get('menu_text')) == '') {
$category = 'xitara.nexus::core.setting.name';
}
return [
'settings' => [
'category' => $category,
'label' => '[VENDOR_SLUG].[PLUGIN_SLUG]::lang.submenu.label',
'description' => '[VENDOR_SLUG].[PLUGIN_SLUG]::lang.submenu.description',
'icon' => 'icon-comments-o',
'class' => '[VENDOR]\[PLUGIN]\Models\Settings',
'order' => 20,
],
];
}