Repeated Breadcrumbs

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:

  1. Create a module override for mod_breadcrumbs
  2. For simplicity, I added the following function directly below defined('_JEXEC') or die at the beginning of the default.php file:
    function 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;
    }
  3. 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