If crumb title and title attributes are empty, crumb item should be skipped

Created on 20 July 2012, about 13 years ago
Updated 17 July 2025, 27 days ago

Hi, if you configure a custom breadcrumb title using "title|attribute title" and both titles are empty, the breadcrumb item is generated empty and the breadcrumb will be something like:

breadcrumb before >  >  breadcrumb after
<!--break-->

The fix is easy. Function _custom_breadcrumbs_get_trail_items() needs to check if the $title is "|". Just add && ($title !="|") to the if:

Correct function:


function _custom_breadcrumbs_get_trail_items($breadcrumb, $titles, $paths) {
  $trail_items = array();

  for ($i = 0; $i < count($titles); $i++) {
    $title = trim($titles[$i]);

    if (($title != '') && ($title != '<none>') && ($title !="|")) {
      // Create a breadcrumb only if there is a title.
      // Include optional html attributes.
      $options = _custom_breadcrumbs_identifiers_option($i + 1, $breadcrumb->bid);
      $crumb_items = _custom_breadcrumbs_create_crumb_items($title, trim($paths[$i]), $options);
      $trail_items = array_merge($trail_items, $crumb_items);
    }
  }
  return $trail_items;
}

Thanks for the attention.

🐛 Bug report
Status

Closed: outdated

Version

2.0

Component

Code

Created by

🇮🇹Italy finex

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024