Breadcrumb
miBreadcrumb class is designed to ease the creation of breadcrumb navigation. Page locations and names are mapped in the $_pageNames variable within the derived class. The tree structure of the pages is mapped in the $_pages variable. Separator can be changed through the value of $_separator variable within the class or runtime. The template of each entry can be changed to get a custom look and feel for each breadcrumb node.
* Using the miBreadcrumb class
<?php
class Breadcrumb extends miBreadcrumb
{
public function __construct()
{
// Map all pages and their corresponding names
$this->_pageNames = array(
'/admin/' => 'Home',
'/admin/administrators.php' => 'Administrators',
'/admin/categories.php' => 'Categories',
);
}
// Map page structure
protected $_pages = array(
'/admin/' => array(
'/admin/administrators.php',
'/admin/categories.php',
)
);
// Override the default separator
protected $_separator = '<img src="/skins/default/admin/images/pointer_right.gif" />';
// Override the default link template
protected $_linkTemplate = '<a href="%%LINK%%?action=dmBack" class="navy">%%NAME%%</a>';
}
$breadcrumb = new Breadcrumb();
// You can override separator runtime if needed
$breadcrumb->setSeparator('>>');
// You can change the link template runtime if needed
$breadcrumb->setLinkTemplate('<a href="%%LINK%%">%%NAME%%</a>');
// Get the breadcrumb html
$breadcrumbHtml = $breadcrumb->getBreadcrumbHtml('/admin/administrators.php');
// $breadcrumbHtml now holds:
// <a href="/admin/">Home</a> >> <a href="/admin/administrators.php">Administrators</a>
// Will output: Home >> Administrators
print($breadcrumbHtml);
?>