Joomla generates incorrect breadcrumb trails for pages that are not associated with menu items. I was working on a website that included a project portfolio for each of my client’s service areas. The breadcrumb trail that Joomla generated was:
Home > Services > Environmental > Services > Environmental > SHA Landscape Inspection
Environmental was the service area and SHA Landscape Inspection was the project name. However, SHA Landscape Inspection did not have a menu item associated with it. To remove these repeated breadcrumbs, follow these steps:
- Create a module override for
mod_breadcrumbs
- For simplicity, I added the following function directly below
defined('_JEXEC') or die
at the beginning of thedefault.php
file:This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersfunction cleanArray ($a) { $names = array(); $b = array(); foreach ($a as $v) { $name = $v->name; if (!array_key_exists ($name, $names)) { $names [$name] = 1; array_push ($b, $v); } } return $b; } - Look for the comment
Generate the trail
. Directly above that line, add the following code:$list = cleanArray($list);
That’s it. The breadcrumb trail will now generate correctly as:
Home > Services > Environmental > SHA Landscape Inspection