Node type / view mode-specific template suggestions

Public

Add template suggestion for node type / view mode-specific templates.

Get raw version
php
  1. // Establish $node.
  2. $node = $variables['node'];
  3.  
  4. // Add template suggestion for node type / view mode-specific templates.
  5. if ($variables['view_mode']) {
  6. $variables['theme_hook_suggestions'][] = 'node__type__' . $node->type;
  7. $variables['theme_hook_suggestions'][] = 'node__mode__' . $variables['view_mode'];
  8. $variables['theme_hook_suggestions'][] = 'node__type__' . $node->type . '__mode__' . $variables['view_mode'];
  9. }