Download the PHP package anroots/menu without Composer
On this page you can find all versions of the php package anroots/menu. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package menu
Short Description A Kohana module to help with building HTML navigation menus
License MIT
Homepage https://github.com/anroots/kohana-menu
Informations about the package menu
HTML Navigation Module for Kohana 3.3
Simplify rendering, building and maintenance of simple, dynamic standardised navigation menus. Instead of...
... we do this:
Basics
You define your menus in Kohana configuration files (see config/menu/navbar.php). Then, in your (main) controller (or template), you construct a new Menu object, set the active link and render it in your template. Done.
Example use case
A WordPress type blog might have...
- Public main navigation menu
- Public footer menu
- Admin-only menu on the public pages, when admin is logged in
- Admin-only menu on the administrator interface
Normally, you'd build HTML views with ul
and li
elements and then write some PHP to highlight the active link. This is
difficult to maintain (DRY) and too much hassle (not to mention ugly).
Instead, describe your (standardised) menus in configuration files and have Kohana do the heavy lifting.
Installation
Place the files in your modules directory.
As a Git submodule:
As a Composer dependency
Copy MODPATH.menu/config/menu/navbar.php
into APPPATH/config/menu/navbar.php
and customize
Activate the module in bootstrap.php
.
Echo menu output in your template
You might wish to instantiate the menu in your main controller, since this gives you a way to interact with the Menu object before it's rendered.
Config files
You can use different config files by setting the factory's $config
parameter.
The view
key of the config files sets the view file that will be used to render the menu.
It defaults to a view file based on the $config
parameter: /views/templates/menu/$config
and if that does not exist falls back on the included /views/templates/menu/default
view file.
For an example, see the included navbar.php
config file.
Example: Load menu configuration based on user role
Marking the current menu item
Use set_current()
to mark the current menu item in your controller
The parameter of set_current()
is the URL value of the respective item or its (numeric) array key
Documentation
The code is mostly commented and more help can be found on the Wiki.
Licence
The Kohana module started out as a fork of the original Kohana Menu module by Bastian Bräu, but is now independently developed under the MIT licence.