Skip to content

nihaopaul/Spark-Menu

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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-improved/1.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';

$nav['blank-holder'] = array('blank' => TRUE);

$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 have 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
  • parent_id - 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 root_value
  • 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).
  • blank - a Boolean statement to insert a blank element, normally used for caps on a list menu

Credits

  • Original developer: David McReynolds @ Daylight Studio
  • Repackaged by: Barnabas Kendall (barnabas@bkendall.biz)
  • blank added by: paul adams @ chaos studio

About

CodeIgniter menu spark

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%