I'm using drupal 8.
I use the view provided by default: "taxonomy term".
I would like to make a presentation of the page (and not only of the node) different according to the term of taxonomy.
I tried with this code (in .theme) and template suggestion :
use Drupal\taxonomy\Entity\Term;
function THEME_NAME_theme_suggestions_page_alter(&$suggestions, &$vars) {
if (\Drupal::routeMatch()->getRouteName() == 'entity.taxonomy_term.canonical' && $tid = \Drupal::routeMatch()->getRawParameter('taxonomy_term')) {
$term = Term::load($tid);
$suggestions[] = 'page__taxonomy__' . $term->getVocabularyId();
}
}
But it does not work because (i think) it is a view.
I tried with the views template suggestion but it works only for the whole page and not for each taxonomy term.
Does anyone have the solution ?