Please use the new Nexus-Plugin: https://github.com/xitara/oc-plugin-nexus
There will be more features like PWA-base or darkmode for backend in near feature
Implements backend sidemenu, custom menus, menu sorting
- clone the repo to folder
plugins/xitara/core
- cd to
plugins/xitara/core
- 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 core-plugin is loaded
*/
if (PluginManager::instance()->exists('Xitara.Core') === true) {
Event::listen('backend.page.beforeDisplay', function ($controller, $action, $params) {
$namespace = (new \ReflectionObject($controller))->getNamespaceName();
if ($namespace == '[VENDOR]\[PLUGIN]\Controllers') {
\Xitara\Core\Plugin::getSideMenu('[VENDOR].[PLUGIN]', '[PLUGIN-SLUG]');
}
});
}
public function register()
{
if (PluginManager::instance()->exists('Xitara.Core') === true) {
BackendMenu::registerContextSidenavPartial(
'[VENDOR].[PLUGIN]',
'[PLUGIN-SLUG]',
'$/xitara/core/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.Core') === true) {
$label .= '::hidden';
}
return [
'[VENDOR-SLUG]' => [
'label' => $label,
'url' => Backend::url('[VENDOR-SLUG]/[PLUGIN-SLUG]/[CONTROLLER'),
'icon' => 'icon-leaf',
'permissions' => ['[VENDOR-SLUG].[PLUGIN-SLUG].*'],
'order' => 500,
],
];
}
public static function injectSideMenu()
{
$i = 0;
return [
'[PLUGIN-SLUG].[CONTROLLER]' => [
'label' => '[VENDOR].[PLUGIN-SLUG]::lang.submenu.[CONTROLLER]',
'url' => Backend::url('[VENDOR]/[PLUGIN-SLUG]/[CONTROLLER]'),
'icon' => 'icon-archive',
'permissions' => ['[VENDOR].[PLUGIN-SLUG].*'],
'attributes' => [ // can be extendet if you need, no limitations
'group' => '[VENDOR].[PLUGIN-SLUG]::lang.submenu.label',
'level' => 1, // optional, default is level 0. adds css-class level-X to li
],
'order' => Core::getMenuOrder('[VENDOR].[PLUGIN-SLUG]') $i ,
],
...
];
}
[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\Core\Models\Config;
and as registration method
public function registerSettings()
{
if (($category = Config::get('menu_text')) == '') {
$category = 'xitara.core::core.config.name';
}
return [
'configs' => [
'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\Config',
'order' => 20,
],
];
}