Thursday, May 21, 2009

Joomla! 1.5 Adding to the Breadcrumb/PathWay through the Joomla Framework

Joomla's JPathway class allows you to add a new item to the pathway to be displayed in the Breadcrumb.

The first thing to do is to access the global JApplication object, then get a reference to the JPathway object.

<?php 
global $mainframe;
$breadcrumbs = &$mainframe->getPathWay();
?>
Adding a breadcrumb is now as simple as calling the JPathway::addItem() method. The addItem method takes a name as the first parameter and a link as the second parameter.
<?php 
$breadcrumbs->addItem( 'My Crumb!', JRoute::_('index.php?option=com_mycrumb') );
?>

If your Item is the last item on the breadcrumb the link will be ignored.