Skip to content

Instantly share code, notes, and snippets.

@heyMP
Created January 17, 2014 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heyMP/8480651 to your computer and use it in GitHub Desktop.
Save heyMP/8480651 to your computer and use it in GitHub Desktop.
Add the View Mode to the classes_array within your entity template. This is so we can theme specific view modes so we can easily switch between different layouts for the same entity using entity view modes
function template_preprocess_entity(&$vars, $hook) {
// Add the View Mode class to the classes_array
if (isset($vars['elements']['#entity_view_mode']['view_mode'])) {
$view_mode = $vars['elements']['#entity_view_mode']['view_mode'];
$vars['classes_array'][] = 'view-mode-' . str_replace('_', '-', $view_mode);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment