oknelok
5/25/2017 - 1:40 PM

Twig example to cycle through taxonomy terms and only show those NOT in the 'tags' and also show image with image style

Twig example to cycle through taxonomy terms and only show those NOT in the 'tags' and also show image with image style

<div>
        <div id="blog-author-information"{{ author_attributes.addClass('author') }}>
          {% trans %}Submitted by {{ author_name }} on {{ date }}{% endtrans %}
          {{ metadata }}
        </div>
        <div id="blog-tags">
        {% for key, item in content.field_blog_tags if key|first != '#' and item['#options']['entity'].vid.getValue()[0]['target_id'] != 'tags' %}
          <div class="blog-taxonomy-item blog-taxonomy-item-{{ item['#title']|lower|replace({'% %': '_'}) }}">
            <img 
              class="blog-taxonomy-image-{{ item['#title']|lower|replace({'% %': '_'}) }}" 
              onMouseOver="this.src='{{ item['#options']['entity'].field_hover_icon.entity.uri.value | image_style('very_small_thumb_25x25') }}'"
              onMouseOut="this.src='{{ item['#options']['entity'].field_default_icon.entity.uri.value | image_style('very_small_thumb_25x25') }}'"
              src="{{ item['#options']['entity'].field_default_icon.entity.uri.value | image_style('very_small_thumb_25x25') }}"
              >
            {{ item }}
          </div>
        {% endfor %}
        </div>
      </div>