Hey! Keep up to date with the project through its beta and public launch by following @getsparks.

 
1
2
0
624 Installs

Basic Information: menu

The Menu library is used to create hierarchical html structures ideal for menu structures.

Contributor : Barnabas
Email : Log in to view
Author Website : http://bkendall.biz/
Spark Website : https://github.com/Barnabas/Spark-Menu
Repository Type : git
Number of Installs : 624

Get the Latest

  • 1.0.0 Pushed July 14th, 2011
    php tools/spark install -v1.0.0 menu Or download this version manually: Get menu-1.0.0.zip

How-To

Menu Library

The Menu library is used to create hierchical html structures ideal for menu structures. It is adapted from the menu class found in FUEL CMS but redistributed here according to the license.

Documentation

This library is capable of outputting standard collapsable menus with helper classes for drop-down or vertical navigation, as well as breadcrumbs and page titles. More complete documentation can be found in the FUEL CMS user guide, but here is a brief overview.

Usage

To create a menu, you must populate an array with the menu items. Then you can output structured HTML suitable for standard navigation by calling the render method. Here's an example:

$this->load->spark('menu/0.0.1');
$nav = array();
$nav['about'] = 'About';
$nav['about/history'] = array('label' => 'History', 'parent_id' => 'about');
$nav['about/contact'] = array('label' => 'Contact', 'parent_id' => 'about');

$nav['products'] = 'Products';
$nav['products/X3000'] = array('label' => 'X3000', 'parent_id' => 'products');

$active = 'about/history';
$menu = $this->menu->render($nav, $active, NULL, 'basic');

echo $menu;
/* echoed output looks something like this
<ul>
    <li class="first active"><a href="/about" title="About">About</a>
        <ul>
            <li class="first"><a href="/about/history" title="History">History</a></li>
            <li class="last active"><a href="/about/contact" title="Contact">Contact</a></li>
        </ul>
    </li>
    <li class="last"><a href="/products" title="Products">Products</a></li>
</ul>
*/

The Menu Array Structure

The menu array can hav the following key/value pairs:

  • id - the id value of the menu item. If none is specified, then the array key value will be used
  • parentid - the parent's id value that the menu item should reside under. Top level (also called root items), should have a root value of NULL or 0 depending on what is specified for the rootvalue
  • label - the text label to display for the menu item
  • location - the link location of the menu item. If none is specified, the array key value will be used
  • attributes - additional HTML link attributes (e.g. target="_blank") to assign to the menu item
  • hidden - whether to display the menu item or not.
  • active - a regular expression that determines whether it should be given active status. If none is specified, it will be the same as the location value (e.g. about/history$|about/contact$). You can also use the :children active magic selector, which will highlight a menu item if it or any of it's sub pages are active. For example, if you have a news page, it allows you to easily highlight the news in the menu for all URI locations of news and news/:children (translates to news$|news/.+ in regular expression).

Credits

  • Original developer: David McReynolds @ Daylight Studio
  • Repackaged by: Barnabas Kendall (barnabas@bkendall.biz)

Older Versions

  • There are no older versions.

Comments

blog comments powered by Disqus