I have a theme set for view mode 'Teaser'. The theme name for this is named like this: node--teaser.tpl.php. So far so good.

Then I created content type 'something' and I would like to create a Teaser theme specific for my new content type 'something'. I have thus named my custom Teaser theme as node--something--teaser.tpl.php. I was expecting this more specific theme name to override theme node--teaser.tpl.php (broader, less specific), but it doesn't work that way. node--teaser.tpl.php has priority over node--something--teaser.tpl.php. Is this really the expected behavior for theme names priority? I would expect the more specific to 'beat' the less specific broader name.

Is it possible to force the more specific theme in template.php function theme_preprocess_node?

1 Answer 1


This page Drupal 7 Template (Theme Hook) Suggestions explains the topic.

To investigate for yourself:

Install Devel module. Add this bit of code to your theme's template.php file (check if the function does not already exist):

function MYTHEME_preprocess_node(&$variables) {

Then inspect the theme_hook_suggestions key. It will look something like this:

enter image description here

This show the suggestions available. To convert it to a tpl.php file just convert underscores to hyphens and add the extension tpl.php.

You can also create your own suggestions by adding this code into preprocess_node:

if ($variables['type'] == 'article' && $variables['view_mode'] == 'teaser') {
  $variables['theme_hook_suggestions'][] = 'node__article__teaser";

Here I am checking for the view mode teaser and adding a theme suggestions based on that. You can check for other conditions as well and add your own suggestions as you please.

Some themes add their own suggestions so always inspect it with dpm() first.

  • Thank you very much for answering this! I will give it a try and let you know later today. Oct 10, 2014 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.