2017 © Pedro Peláez
 

cakephp-plugin cakephp-menu-manager

MenuManager plugin for CakePHP

image

radotch/cakephp-menu-manager

MenuManager plugin for CakePHP

  • Wednesday, July 11, 2018
  • by radotch
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

MenuManager plugin for CakePHP

Requirements

 - php >= 5.6.x (recomended >= 7.1)
 - cakephp  ^3.5

For testing:, (*1)

 - phpunit ^5.7.14|^6.x

Features

  • Create Menu
  • Create Menu Links associated to Menu
  • Menu Links have Tree structure. It's make easy to create dropdowns, accordeon or other specific kind of Menu.
  • Menu Links positions
  • Translations

Installation

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

Load plugin

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)

Migrations

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

Usage

Control panel

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)

Get Data

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)

Translation

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)

Display Menu

At this stage to display menu you have to write your own code., (*20)

Good luck!, (*21)

The Versions

11/07 2018

dev-master

9999999-dev

MenuManager plugin for CakePHP

  Sources   Download

MIT

The Requires

 

The Development Requires

11/07 2018

1.0.0

1.0.0.0

MenuManager plugin for CakePHP

  Sources   Download

MIT

The Requires

 

The Development Requires