2017 © Pedro Peláez
 

cakephp-plugin cakephp-menulink

MenuLink plugin for CakePHP

image

rrd108/cakephp-menulink

MenuLink plugin for CakePHP

  • Friday, July 6, 2018
  • by rrd
  • Repository
  • 1 Watchers
  • 0 Stars
  • 243 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 4 Open issues
  • 2 Versions
  • 46 % Grown

The README.md

MenuLink plugin for CakePHP 3

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)

Installation

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

Usage

Load the plugin

Load the plugin in your /config/bootstrap.php file, (*4)

Plugin::load('MenuLink');

Load and use the helper

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)

Override the Html helper

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>

The Versions

06/07 2018

dev-master

9999999-dev

MenuLink plugin for CakePHP

  Sources   Download

MIT

The Requires

 

The Development Requires

18/07 2017

1.0.0

1.0.0.0

MenuLink plugin for CakePHP

  Sources   Download

MIT

The Requires

 

The Development Requires