Skip to main content

theme

Drupal 8: Theme suggestions for content type AND view mode.

I was trying to theme a specific vocabulary and a specific view mode and the suggestions, by default, didn't allow for this. After some searching I came across this article, which mentioned using the hook:

hook_theme_suggestions_HOOK_alter().

So, I added the function below in my .theme file to make the following template suggestion available: 'taxonomy_term__VOCABULARY__VIEW_MODE'


Getting a themed views title within a style tpl file

I ran into an issue today where I needed to get a themed views title from within a views row style template file (tpl). I tried using drupal_get_title() and menu_get_item() but the title elements were all blank for these. Next I inspected the $views object looking for the themed title but it was not listed. Finally, I discovered within $views->build_info the title and substitutions variables.