Joomla 1.5 Custom Breadcrumbs
Posted by: gbluma
on Jul 9, 2009
Joomla seems to have everything figured out — Breadcrumb support is no exception.
Recently we were writing some custom component for a client and needed to handle the breadcrumbs in a special way that Joomla couldn't manage automatically.
As a simplified example, imagine we redirect a user to a component that isn't attached to a menu. We would expect the breadcrumbs to simply output "Home" and provide a link back to the index of the site.
Home
(Notice: Home is not a link while on homepage)
But let's try to make this a little more usable. In our example, let's say that we've landed on a Product Index page. If we use the code:
global $mainframe;
$app =& JFactory::getApplication();
$pathway =& $app->getPathway(); // get the pathway object we want to modify
$pathway->addItem('Products'); // add the text, but no link
So If we're on the product index of our component, we would see this as our breadcrumb:
Home > Products
(Notice: "Home" is linked, "Products" is not)
Adding text is nice, but let's up the ante. Let's also say in our example, that the user clicks a specific product on our product index ("The Breadslic0r 3000"). As we go to that page, we expect products to be clickable and for "The Breadslic0r 3000" to show up in the breadcrumbs as the current item.
Let's see the code for it:
global $mainframe;
$app =& JFactory::getApplication();
$pathway =& $app->getPathway(); // get the pathway object we want to modify
$pathway->addItem('Products', 'index.php?option=com_products&task=products'); // add the text, this time w/ link
$pathway->addItem('The Breadslic0r 3000'); // add the text, w/ no link
(Notice: this is a generic example, in a production environment I'd expect the product name to be added dynamically)
And now let's see the output:
Home > Products > The Breadslic0r 3000
(Note: "Home" and "Products" are both linked, "The Breadslic0r 3000" is not)
It's not the most amazing thing ever, but it might be useful to know. Let us know if this has been useful for you!

felipe
said:
|
na I use to add the path way to componette that dont have one. Thaks, it helped me alot. |
|
Shyam
said:
|
Thanks Thanks man you have solved my problem which was pending by last one month. now it's working fine. |
|
Rahul Anand
said:
|
Nice Article Hey, Such a nice article. Very helpful. Thanks for publishing such a fantastic article for us. Regards Rahul Anand |
|
jan
said:
|
... Thank you for this!! I've been looking for this solution a whole day: instaling components, modules, reorganizing menus etc...but nothing works so well as this solution, Thanks! |
|
Del WHeeler
said:
|
DRW Ok, it sounds great, but if you are not that familiar with Joomla you would need to know where to place this code. As Uri posted above "where do we add these changes?" Everyone just ignored his question. This looks like a solution i need as well but I have no clue where to place this code. Can someone please help? I have an article with an image with a link, and my bread crumbs don't work. Thanks, Del |
|
