You are here

function breadcrumb_extra_field_entity_view in Breadcrumb Extra Field 7

Same name and namespace in other branches
  1. 8 breadcrumb_extra_field.module \breadcrumb_extra_field_entity_view()
  2. 2.x breadcrumb_extra_field.module \breadcrumb_extra_field_entity_view()

Implements hook_entiy_view().

File

./breadcrumb_extra_field.module, line 50
Main module file.

Code

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) {

    // Add extra field value only if showed.
    $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(),
      ),
    );
  }
}