diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceFormatterBase.php b/core/modules/entity_index a8b4fee..994aea2 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceFormatterBase.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceFormatterBase.php @@ -18,6 +18,18 @@ abstract class EntityReferenceFormatterBase extends FormatterBase { /** + * Overrides \Drupal\field\Plugin\Type\Formatter\FormatterBase::view(). + */ + public function view(EntityInterface $entity, $langcode, array $items) { + $addition = parent::view($entity, $langcode, $items); + + // Add a target type variable. + $addition[$this->field['field_name']]['#entity_reference_target_type'] = $this->field['settings']['target_type']; + + return $addition; + } + + /** * Overrides \Drupal\field\Plugin\Type\Formatter\FormatterBase::prepareView(). * * Mark the accessible IDs a user can see. We do not unset unaccessible diff --git a/core/themes/bartik/css/style-rtl.css b/core/themes/bartik/css/style-rtl.css index 22994c2..68eaa13 100644 --- a/core/themes/bartik/css/style-rtl.css +++ b/core/themes/bartik/css/style-rtl.css @@ -88,11 +88,11 @@ ul.tips { margin-left: 20px; margin-right: 0; } -.field-type-entity-reference .field-label { +.field-type-entity-reference-taxonomy-term .field-label { padding-left: 5px; padding-right: 0; } -.field-type-entity-reference ul.links li { +.field-type-entity-reference-taxonomy-term ul.links li { padding: 0 0 0 1em; float: right; } diff --git a/core/themes/bartik/css/style.css b/core/themes/bartik/css/style.css index adebe80..4e783e8 100644 --- a/core/themes/bartik/css/style.css +++ b/core/themes/bartik/css/style.css @@ -117,7 +117,7 @@ ul.contextual-links, ul.links, ul.primary, .item-list .pager, -div.field-type-entity-reference, +div.field-type-entity-reference-taxonomy-term, div.messages, div.meta, p.comment-time, @@ -626,28 +626,28 @@ h1#page-title { float: left; /* LTR */ margin: 1px 20px 0 0; /* LTR */ } -.field-type-entity-reference { +.field-type-entity-reference-taxonomy-term { margin: 0 0 1.2em; } -.field-type-entity-reference .field-label { +.field-type-entity-reference-taxonomy-term .field-label { font-weight: normal; margin: 0; padding-right: 5px; /* LTR */ } -.field-type-entity-reference .field-label, -.field-type-entity-reference ul.links { +.field-type-entity-reference-taxonomy-term .field-label, +.field-type-entity-reference-taxonomy-term ul.links { font-size: 0.8em; } -.view-mode-teaser .field-type-entity-reference .field-label, -.view-mode-teaser .field-type-entity-reference ul.links { +.view-mode-teaser .field-type-entity-reference-taxonomy-term .field-label, +.view-mode-teaser .field-type-entity-reference-taxonomy-term ul.links { font-size: 0.821em; } -.field-type-entity-reference ul.links { +.field-type-entity-reference-taxonomy-term ul.links { padding: 0; margin: 0; list-style: none; } -.field-type-entity-reference ul.links li { +.field-type-entity-reference-taxonomy-term ul.links li { float: left; /* LTR */ padding: 0 1em 0 0; /* LTR */ white-space: nowrap; diff --git a/core/themes/bartik/template.php b/core/themes/bartik/template.php index 39e06aa..82775a3 100644 --- a/core/themes/bartik/template.php +++ b/core/themes/bartik/template.php @@ -131,6 +131,12 @@ function bartik_menu_tree($variables) { * Implements theme_field__field_type(). */ function bartik_field__entity_reference($variables) { + // We only want to customize the output of fields that reference taxonomy_term + // entities. + if (isset($variables['element']['#entity_reference_target_type']) && $variables['element']['#entity_reference_target_type'] != 'taxonomy_term') { + return theme_field($variables); + } + $output = ''; // Render the label, if it's not hidden. @@ -141,10 +147,13 @@ function bartik_field__entity_reference($variables) { // Render the items. $output .= ($variables['element']['#label_display'] == 'inline') ? '