View source
<?php
define('BREADCRUMB_EXTRA_FIELD_ALLOWED_ENTITY_TYPES', serialize(array(
'node',
'user',
'taxonomy_term',
'comment',
'bean',
)));
define('BREADCRUMB_EXTRA_FIELD_ADMIN', 'breadcrumb_extra_field_admin');
function breadcrumb_extra_field_field_extra_fields() {
$admin = variable_get('breadcrumb_extra_field_admin', array());
$entity_info = entity_get_info();
$extra = [];
foreach ($entity_info as $entity_type_key => $entity_type) {
$bundle_options = array();
foreach ($entity_type['bundles'] as $bundle_key => $bundle) {
if (!empty($admin[$entity_type_key]) && isset($admin[$entity_type_key][$bundle_key]) && $admin[$entity_type_key][$bundle_key]) {
$extra[$entity_type_key][$bundle_key] = array(
'display' => array(
'breadcrumb_extra_field' => array(
'label' => t('Breadcrumb'),
'description' => t('Breadcrumb'),
'weight' => 0,
),
),
);
}
}
}
return $extra;
}
function breadcrumb_extra_field_entity_view($entity, $type, $view_mode, $langcode) {
list(, , $bundle) = entity_extract_ids($type, $entity);
$extra_fields = field_extra_fields_get_display($type, $bundle, $view_mode);
if (!empty($extra_fields['breadcrumb_extra_field']) && $extra_fields['breadcrumb_extra_field']['visible'] == TRUE) {
$entity->content['breadcrumb_extra_field'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'field',
'breadcrumb-extra-field',
),
),
'breadcrumb' => array(
'#theme' => 'breadcrumb',
'#weight' => $extra_fields['breadcrumb_extra_field']['weight'],
'#breadcrumb' => drupal_get_breadcrumb(),
),
);
}
}
function breadcrumb_extra_field_permission() {
return array(
'administer breadcrumb extra field' => array(
'title' => t('Administer breadcrumb extra field'),
'description' => t('Perform administration tasks for breadcrumb extra field.'),
),
);
}
function breadcrumb_extra_field_menu() {
$items = array();
$items['admin/structure/breadcrumb-extra-field'] = array(
'title' => 'Settings',
'access callback' => 'user_access',
'access arguments' => array(
'administer breadcrumb extra field',
),
'page callback' => 'drupal_get_form',
'page arguments' => array(
'breadcrumb_extra_field_admin',
),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
'file' => 'breadcrumb_extra_field.admin.inc',
);
return $items;
}