iu-8.x-1.x-dev/templates/field/field.html.twig

templates/field/field.html.twig
{#
/**
 * @file
 * Theme override for a field.
 *
 * Available variables:
 * - attributes: HTML attributes for the containing element.
 * - label_hidden: Whether to show the field label or not.
 * - title_attributes: HTML attributes for the title.
 * - label: The label for the field.
 * - multiple: TRUE if a field can contain multiple items.
 * - items: List of all the field items. Each item contains:
 *   - attributes: List of HTML attributes for each item.
 *   - content: The field item's content.
 * - entity_type: The entity type to which the field belongs.
 * - field_name: The name of the field.
 * - field_type: The type of the field.
 * - label_display: The display settings for the label.
 *
 * @see template_preprocess_field()
 */
#}

{%
  set field_name = ('field_' in field_name) ? field_name : 'field_' ~ field_name
%}

{%
  set classes = [
    field_name|clean_class,
    'field-type-' ~ field_type|clean_class,
    'field-label-is-' ~ label_display|clean_class,
  ]
%}

{%
  set title_classes = [
    'field-label',
    label_display|clean_class
  ]
%}

{% if label_hidden %}
  {% if multiple %}
    <p{{ attributes.addClass(classes) }}>
      {% for item in items %}
        <span{{ item.attributes }}>{{ item.content }}</span>
      {% endfor %}
    </p>
  {% else %}
    {% for item in items %}
      <p{{ attributes.addClass(classes) }}>{{ item.content }}</p>
    {% endfor %}
  {% endif %}
{% else %}
  <p{{ attributes.addClass(classes) }}>
    <strong{{ title_attributes.addClass(title_classes) }}>{{ label }}:</strong>
    {% if label_display != 'visually_hidden' and label_display != 'inline' %}
      <br/>
    {% endif %}
    {% if multiple %}
      <span class="field-multiple">
    {% endif %}
    {% for item in items %}
      <span{{ item.attributes }}>{{ item.content }}</span>
    {% endfor %}
    {% if multiple %}
      </span>
    {% endif %}
  </p>
{% endif %}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc