Taxonomy term

Some extra's for taxonomy-term components.

Extra template suggestions

Added 2 more specific template suggestions. One for view mode and one for vocabulary name and view-mode for all taxonomy terms

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'taxonomy_term' -->
<!-- FILE NAME SUGGESTIONS:
   x taxonomy-term--faq--full.html.twig
   x taxonomy-term--full.html.twig
   * taxonomy-term--556.html.twig
   * taxonomy-term--faq.html.twig
   * taxonomy-term.html.twig
-->

In above example:

  • full is the view-mode
  • faq is the vocabulary name

Better classes

The classes on taxonomy-terms has been changed to:

{%
  set classes = [
    'taxonomy-term',
    'taxonomy-term--' ~ term.bundle|clean_class,
    view_mode ? 'taxonomy-term--' ~ view_mode|clean_class,
    view_mode ? term.bundle|clean_class ~ '--' ~ view_mode|clean_class,
  ]
%}

Which gives you the following classes:

.taxonomy-term {}
.taxonomy-term--faq {}
.taxonomy-term--full {}
.faq--full {} 

Extra functions

Create the possibility to have vocabulary-specific preprocess functions.

So inside taxonomy-term--faq.theme you could now have this function:

<?php

/**
 * Implements template_preprocess_hook().
 */
function compony_preprocess_taxonomy_term__faq(&$variables, $hook) {
  // Do custom preprocessing here, 
  // only for FAQ taxonomy-terms. 
}

(Docs: Extending hooks yourself)

Specifications

Machine name

taxonomy-term

Built upon

Drupal Core

Perks

Responsive
Accessible

Building blocks

HTML

Stats

Public component
106 downloads
No open issue

Contributors