dev-master
9999999-devMenuLink plugin for CakePHP
MIT
The Requires
The Development Requires
1.0.0
1.0.0.0MenuLink plugin for CakePHP
MIT
The Requires
The Development Requires
MenuLink plugin for CakePHP
This is a handy and really simple plugin for displaying the active menu item based on the url. If you have a link pointing to the current url, it will get an "active" css class. You should add your own css definitin for a.active
to your css file., (*1)
You can install this plugin into your CakePHP application using composer., (*2)
The recommended way to install composer packages is:, (*3)
composer require rrd108/cakephp-menulink
Load the plugin in your /config/bootstrap.php
file, (*4)
Plugin::load('MenuLink');
You can load the helper in two different ways, the reccomended way or the override way., (*5)
In your /src/View/AppView.php
file at your initialize()
method load the helper like this., (*6)
$this->loadHelper('MenuLink.MenuLink');
In this case in your view files you should use the helper like this., (*7)
$this->MenuLink->menuLink( 'Link text', [ 'controller' => 'posts', 'action' => 'index' ], [$options] );
The menuLink call handles the same paramaeters as the core Html helper's link method, (*8)
This is a little bit more comfortable way to do the same above. As this way overrides the core Html helper it can conflict with other helpers trying to override the same thing., (*9)
In your /src/View/AppView.php
file at your initialize()
method load the helper like this., (*10)
$this->loadHelper('Html', ['className' => 'MenuLink.MenuLink']);
In this case in your view files you should use the helper like this., (*11)
$this->Html->menuLink( 'Link text', [ 'controller' => 'posts', 'action' => 'index' ], [$options] );
The menuLink call handles the same paramaeters as the core Html helper's link method, (*12)
In both ways your active link will look like this, but others will do not have this css class definition., (*13)
<a href="/posts/index" class="active">Link text</a>
MenuLink plugin for CakePHP
MIT
MenuLink plugin for CakePHP
MIT