Remove duplicates from breadcrumbs in Joomla content

yellowwebmonkey web services

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

About YellowWebMonkey

YellowWebMonkey Web design offers reliable website design, SEO and digital marketing services for Joomla, WordPress and Shopify sites. We strive to be a one-stop shop for all your web needs.

Recent Posts

Follow Us