You are here

function template_preprocess_easy_breadcrumb in Easy Breadcrumb 7.2

Process variables for easy-breadcrumb.tpl.php.

See also

easy-breadcrumb.tpl.php

File

./easy_breadcrumb.module, line 143
The Easy Breadcrumb module provides a block to be embedded in any page.

Code

function template_preprocess_easy_breadcrumb(&$variables) {
  $breadcrumbs = _easy_breadcrumb_build_items();
  if (module_exists('schemaorg')) {
    $variables['list_type'] = 'https://schema.org/BreadcrumbList';
  }
  else {
    $variables['list_type'] = 'http://data-vocabulary.org/Breadcrumb';
  }
  foreach ($breadcrumbs as $i => $breadcrumb) {
    if (isset($breadcrumb['url'])) {
      $variables['breadcrumb'][$i] = '<span itemprop="title">';
      $parsed_query = array();
      $parsed_url = parse_url($breadcrumb['url']);
      if (isset($parsed_url['query'])) {
        parse_str($parsed_url['query'], $parsed_query);
      }
      $variables['breadcrumb'][$i] .= l($breadcrumb['content'], $parsed_url['path'], array(
        'attributes' => array(
          'class' => $breadcrumb['class'],
        ),
        'query' => $parsed_query,
        'html' => !empty($breadcrumb['html']) ? $breadcrumb['html'] : FALSE,
      ));
      $variables['breadcrumb'][$i] .= '</span>';
    }
    else {
      $class = implode(' ', $breadcrumb['class']);
      $variables['breadcrumb'][$i] = '<span class="' . $class . '" itemprop="title">' . $breadcrumb['content'] . '</span>';
    }
  }
  $variables['segments_quantity'] = isset($variables['breadcrumb']) ? count($variables['breadcrumb']) : 0;
  $variables['separator_ending'] = variable_get(EasyBreadcrumbConstants::DB_VAR_SEPERATOR_ENDING, FALSE) ? 0 : 1;
  $variables['separator'] = filter_xss(variable_get(EasyBreadcrumbConstants::DB_VAR_SEGMENTS_SEPARATOR, '»'));
}