Actions

J1.5

How to add breadcrumbs

From Joomla! Documentation

Revision as of 07:40, 28 May 2013 by Wilsonge (Talk | contribs)

Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Split-icon.png
Split Page into Specific Joomla! Versions - J2.5 and J3.1

It has been suggested that this article or section be split into specific version Namespaces. (Discuss). If version split is not obvious, please allow split request to remain for 1 week pending discussions. Proposed since 10 months ago.

Breadcrumbs are nice way to display the connection from the root. It gives you a hierarchical representation with click able links so that user can visit upper links easily. Breadcrumbs can be added in templates by using the object returned by $mainframe->getPathWay(). The member function addItem() allows to add a breadcrumb with the title of choice.

There are two parameters used for breadcrumbs creation process, and the first parameter is the title for the breadcrumb and the second parameter is the URL. If we do not need the breadcrumb to work like a link then we need to simply pass a blank string and then it will not work like a click able URL. This term is useful for hierarchical components where we have subcategories: we can generate a link to each and then end with the title of the current record or category.

The JPathway is currently used by the breadcrumbs module. If you are adding a new component and have already configured breadcrumbs, you may need to go into the breadcrumbs configuration and add the menu item for you component to the selection on the menu selelist.

Example

Joomla 1.5 A view's view.php could look something like this.

class exampleViewdefault extends JView {
	function display($tpl = null) {

		
		$mainframe = &JFactory::getApplication();
		$document  = &JFactory::getDocument();		
		$pathway   =& $mainframe->getPathway();


		JHTML::_('behavior.modal');
		$model =& $this->getModel();
		$data = $model->getData();

		$this->assignRef( 'events', $data);

		$document->setTitle( $this->events['name'] );		
		$pathway->addItem($this->events['name'], '');

		parent::display($tpl);

	}
}


Joomla 2.5 The display function from a view's view.php for joomla 2.5 could look something like this.

public function display($tpl = null) 
{
        
$app	= JFactory::getApplication();
$pathway = $app->getPathway();
$pathway->addItem('My Added Breadcrumb Link', 'http://www.yourdomain.tld');

parent::display($tpl);

}

See Also