11
July
2016

Remove duplicates from breadcrumbs in Joomla content

This is a common scenario:  Your single articles show a duplicate breadcrumb when the article doesn't have an associated menu item.  Typically the first one is the menu item for the category blog menu item that the article would fall under.  The second is the category itself.

 

The reason this happens is that the conditional statement in the template for mod_breadcrumbs checks to see if the LINK of the previous breadcrumb is the same as the LINK for one it is generating.  Since those items I mentioned have different links, it doesn't see them as duplicates. You have to add the condition to see if the NAME is the same as the previous one.

 

To fix this, you need to create a template override for the module layout.  To do this download modules/mod_breadcrumb/tmpl/default.php and make the changes below:

 

Change Line 30 from:

if ($i == 1 && !empty($list[$i]->link) && !empty($list[$i - 1]->link) && $list[$i]->link == $list[$i - 1]->link)

to

if (($i != 1 && !empty($list[$i]->link) && !empty($list[$i - 1]->link)) && ($list[$i]->link == $list[$i - 1]->link || $list[$i]->name == $list[$i - 1]->name))

 

Upload your revised default.php to templates/YOUR_TEMPLATE_NAME/mod_breadcrumb/default.php

Categories: Joomla Core

blog comments powered by Disqus

YellowWebMonkey Clients

Get Started with YellowWebMonkey

Invalid Input

Invalid web address.

Invalid Input

Invalid Input

Joomla Certified Administrator

Joomla Maintenance Plans

Get started with reliable monthly care provided by a Joomla certified company.

Invalid Input

Invalid web address.

Invalid Input

Invalid Input

Hire YellowWebMonkey

Invalid Input

Invalid web address.

Invalid Input

Invalid Input

Joomla Certified Administrator

Get Started Now

Invalid Input

Invalid web address.

Invalid Input

Invalid Input

Joomla Certified Administrator

Request More Info

Invalid Input

Invalid web address.

Invalid Input

Invalid Input

Joomla Certified Administrator

Contact YellowWebMonkey

Invalid Input

Invalid web address.

Invalid Input

Invalid Input

Joomla Certified Administrator

Sign Up with YellowWebMonkey

Invalid Input

Invalid web address.

Invalid Input

Invalid Input

Joomla Certified Administrator

Same Day Estimate

Invalid Input

Invalid web address.

Invalid Input

Invalid Input

Joomla Certified Administrator