public function FacetapiUrlProcessorStandard::setBreadcrumb in Facet API 7
Same name and namespace in other branches
- 6.3 plugins/facetapi/url_processor_standard.inc \FacetapiUrlProcessorStandard::setBreadcrumb()
- 7.2 plugins/facetapi/url_processor_standard.inc \FacetapiUrlProcessorStandard::setBreadcrumb()
Implements FacetapiUrlProcessor::setBreadcrumb().
Overrides FacetapiUrlProcessor::setBreadcrumb
File
- plugins/
facetapi/ url_processor_standard.inc, line 94 - The standard url processor class.
Class
- FacetapiUrlProcessorStandard
- Url processor plugin that retrieves facet data from the query string.
Code
public function setBreadcrumb() {
$breadcrumb = drupal_get_breadcrumb();
// Gets search keys and active items form the adapter.
$keys = $this->adapter
->getSearchKeys();
$active_items = $this->adapter
->getAllActiveItems();
$item = menu_get_item();
// Initializes base breadcrumb query.
$query = $this->params;
unset($query[$this->filterKey]);
// Adds the current search to the query.
if ($keys) {
// The last item should be text, not a link.
$breadcrumb[] = $active_items ? l($keys, current_path(), array(
'query' => $query,
)) : check_plain($keys);
}
// Adds filters to the breadcrumb trail.
$last = end($active_items);
foreach ($active_items as $item) {
$query[$this->filterKey][] = rawurlencode($item['field alias']) . ':' . $item['value'];
// Replaces with the mapped value.
$value = $this->adapter
->getMappedValue($item['facets'][0], $item['value']);
// The last item should be text, not a link.
if ($last == $item) {
$breadcrumb[] = !empty($value['#html']) ? $value['#markup'] : check_plain($value['#markup']);
}
else {
// Appends the filter to the breadcrumb trail.
$breadcrumb[] = l($value['#markup'], current_path(), array(
'query' => $query,
'html' => !empty($value['#html']),
));
}
}
// Sets the breadcrumb trail with the keys and filters.
drupal_set_breadcrumb($breadcrumb);
}