You are here

function _custom_breadcrumbs_create_crumb in Custom Breadcrumbs 7

Same name and namespace in other branches
  1. 6 custom_breadcrumbs.module \_custom_breadcrumbs_create_crumb()

Private function for custom breadcrumb to create a crumb item

Parameters

$title: The human readable title to be rendered by the browser

$original_path: The desired URI and/or special identifier

1 call to _custom_breadcrumbs_create_crumb()
custom_breadcrumbs_node_view in ./custom_breadcrumbs.module
Implements hook_node_view().

File

./custom_breadcrumbs.module, line 172
Provide custom breadcrumbs for node-type pages.

Code

function _custom_breadcrumbs_create_crumb($title, $original_path) {

  // Decode title to properly handle special characters.
  $title = decode_entities($title);

  // Collapse double slashes to one.
  $original_path = preg_replace('/\\/+/', '/', $original_path);

  // Removing leading and trailing slashes.
  $original_path = preg_replace('/^\\/|\\/+$/', '', $original_path);

  // Supress "Undefined Offset" error.
  @(list($identifier, $path) = explode("|", $original_path, 2));
  if ($path) {
    switch ($identifier) {
      case '<pathauto>':
        if (module_exists('pathauto')) {
          module_load_include('inc', 'pathauto', 'pathauto');
          $patharray = explode('/', $path);
          foreach ($patharray as $k => $v) {
            $patharray[$k] = pathauto_cleanstring($v);
          }
          $path = implode('/', $patharray);
          $crumb = l($title, $path);
        }
        else {
          $crumb = l($title, $path);
        }
        break;
      default:
        $crumb = l($title, $original_path);
    }
  }
  else {

    // This may be just be a single identifier.
    switch ($identifier) {
      case '<none>':
        $crumb = check_plain($title);
        break;
      default:
        $crumb = l($title, $original_path);
    }
  }
  return $crumb;
}