You are here

function view_mode_templates_preprocess in View Mode Templates 7

Implements hook_preprocess().

File

./view_mode_templates.module, line 30
Templates for Entity View Modes

Code

function view_mode_templates_preprocess(&$variables, $hook) {
  if (array_key_exists($hook, entity_get_info())) {
    $entity_type = $variables['elements']['#entity_type'];
    $bundle = $variables['elements']['#bundle'];
    $view_mode = $variables['elements']['#view_mode'];
    $variables['theme_hook_suggestions'][] = $entity_type . '__' . $bundle . '__' . $view_mode;
    $variables['theme_hook_suggestions'][] = $entity_type . '__' . $bundle;
    $variables['theme_hook_suggestions'][] = $entity_type . '__' . $view_mode;
  }
}