dev-master
9999999-devMenuManager plugin for CakePHP
MIT
The Requires
The Development Requires
1.0.0
1.0.0.0MenuManager plugin for CakePHP
MIT
The Requires
The Development Requires
MenuManager plugin for CakePHP
- php >= 5.6.x (recomended >= 7.1) - cakephp ^3.5
For testing:, (*1)
- phpunit ^5.7.14|^6.x
You can install this plugin into your CakePHP application using composer., (*2)
The recommended way to install plugin is:, (*3)
composer require radotch/cakephp-menu-manager
To load plugin add next line in bootstrap() method in Application.php file:, (*4)
$this->addPlugin('MenuManager', ['autoload' => true, 'routes' => true]);
or you can use object way, (*5)
$plugin = new \MenuManager\Plugin(array $config = []) ->disable('bootstrap') ->enable('routes'); $this->addPlugin($plugin)
Prior 3.6.0 use next:, (*6)
Plugin::load('MenuManager', ['autoload' => true, 'routes' => true]);
And you are ready to use MenuManager plugin., (*7)
Once the plug-in is available execute Migrations to create required tables:, (*8)
$ path/to/project> bin/cake migrations migrate --plugin MenuManager
Note: If table i18n already exists migration will not try to create it., (*9)
There is available initial seed which can be used if cover application needs on start or just for test purposes:, (*10)
$ path/to/project> bin/cake migrations seed --plugin MenuManager
Plugin's Control panel is available on '/admin/menu-manager/'. Do not forget to restrict access, (*11)
Now you can create Menus and add Menu Links., (*12)
To get Menu Links in hierarchical structure use 'threaded' finder:, (*13)
// In controller $menu = $this->TableRegistry::getTableLocator() ->get('MenuManager.Menus') ->find() ->contain(['MenuLinks' => ['finder' => 'threaded']]) ->where([$whereConditions]);
Or, (*14)
// In controller $menuLinks = $this->TableRegistry::getTableLocator() ->get('MenuManager.MenuLinks') ->find('threaded') // Some query requirements ->where(['menu_id' => $menuId]);
When create or update menu Link you can set link's position. If is changed at this point the change will not affect other links. All other Menu Link positions must be changed by hand., (*15)
Sorry about that and later when I have little more time I'll automate it. Also support will be accepted and appreciated., (*16)
To be able to add translations about Menu and Menu Links set next Configuration as associative array or list:, (*17)
$language = [ 'bg_BG' => 'Bulgarian', 'en' => 'English', 'en_US' => 'English (United States)' ]; Configure::write('MenuManager.Translation.Languages', $languages);
or, (*18)
$plugin = new \MenuManager\Plugin($config = []); $plugin->setTranslations($languages);
The best place is bootstrap() method at Application.php I think., (*19)
At this stage to display menu you have to write your own code., (*20)
Good luck!, (*21)
MenuManager plugin for CakePHP
MIT
MenuManager plugin for CakePHP
MIT