Skip to content

Instantly share code, notes, and snippets.

@mrded
Created October 10, 2013 16:43
Show Gist options
  • Save mrded/6921555 to your computer and use it in GitHub Desktop.
Save mrded/6921555 to your computer and use it in GitHub Desktop.
Split templates for entity by view_mode
<?php
/**
* Implements hook_preprocess_entity().
*/
function wj_profile_preprocess_entity(&$vars) {
switch ($vars['entity_type']) {
case 'profile2':
$vars['theme_hook_suggestions'][] = "profile2__profile__{$vars['view_mode']}";
$function_name = "wj_profile_preprocess_profile2_profile_{$vars['view_mode']}";
if (function_exists($function_name)) {
$function_name($vars);
}
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment