J3.x

Difference between revisions of "How to add breadcrumbs"

From Joomla! Documentation

(3.x version)
 
(Some markup, URL and language changes.)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{version/tutor|3.x}}
+
<noinclude><languages /></noinclude>
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.
+
<noinclude>{{Joomla version|version=3.x|comment=<translate><!--T:1-->
 +
series</translate>}}</noinclude>
 +
{{-}}
  
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.
+
<translate>
 +
<!--T:2-->
 +
Breadcrumbs are a nice way to display the connection from the root. It gives you a hierarchical representation with clickable 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 you to add a breadcrumb with the title of your choice.</translate>
 +
 
 +
<translate>
 +
<!--T:3-->
 +
There are two parameters used for breadcrumbs creation process. The first is the title for the breadcrumb and the second is the URL. If we do not need the breadcrumb to work as a link then we simply pass a blank string and it will not be a clickable 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.
 +
</translate>
 +
 
 +
<translate>
 +
<!--T:4-->
 +
The ''JPathway'' is 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 of your component to the menu selection list.
 +
</translate>
  
 
== Example ==
 
== Example ==
{{JVer|{{CurrentSTSVer|minor}}}} The display function from a view's view.php for Joomla! 3.x could look something like this.
+
{{JVer|{{CurrentSTSVer|minor}}}} <translate><!--T:5-->
<pre>
+
The display function from a view's ''view.php'' for Joomla! 3.x could look like this.</translate>
public function display($tpl = null)  
+
 
 +
<syntaxhighlight lang="php">
 +
public function display($tpl = null)
 
{
 
{
       
+
 
 
$app = JFactory::getApplication();
 
$app = JFactory::getApplication();
 
$pathway = $app->getPathway();
 
$pathway = $app->getPathway();
Line 19: Line 34:
  
 
}
 
}
</pre>
+
</syntaxhighlight>
  
== See Also==
+
<translate>
* http://docs.joomla.org/JPathway
+
== See Also == <!--T:6-->
* http://api.joomla.org/11.4/Joomla-Platform/Application/JPathway.html
+
* [https://api.joomla.org/cms-2.5/classes/JPathway.html JPathway in the Joomla! API]
* http://docs.joomla.org/API16:JPathway
+
</translate>
  
[[Category:Tutorials]][[Category:Component Development]]
+
<noinclude>
 +
<translate>
 +
<!--T:7-->
 +
[[Category:Tutorials]]
 +
[[Category:Component Development]]
 +
</translate>
 +
</noinclude>

Latest revision as of 18:23, 19 October 2022

Other languages:
English • ‎Nederlands • ‎español • ‎français
Joomla! 
3.x
series

Breadcrumbs are a nice way to display the connection from the root. It gives you a hierarchical representation with clickable 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 you to add a breadcrumb with the title of your choice.

There are two parameters used for breadcrumbs creation process. The first is the title for the breadcrumb and the second is the URL. If we do not need the breadcrumb to work as a link then we simply pass a blank string and it will not be a clickable 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 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 of your component to the menu selection list.

Example[edit]

Joomla 3.10 The display function from a view's view.php for Joomla! 3.x could look 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[edit]