Skip to content

Instantly share code, notes, and snippets.

@mglaman
Created January 13, 2014 17:56
Show Gist options
  • Save mglaman/8404838 to your computer and use it in GitHub Desktop.
Save mglaman/8404838 to your computer and use it in GitHub Desktop.
Simple Drupal module to add display view modes
name = Custom Entity Display Modes
description = Adds additional display modes
core = 7.x
/**
* Implements hook_entity_info_alter().
*
* Adds a new order view mode
*/
function mymodule_view_modes_entity_info_alter(&$entity_info) {
$entity_info['node']['view modes']['custom'] = array(
'label' => t('Custom Display'),
'custom settings' => FALSE,
);
}
function mymodule_view_modes_preprocess_node(&$vars) {
if ($vars['node']->type == 'node_type' && $vars['view_mode'] == 'custom') {
$vars['theme_hook_suggestions'][] = 'node__node_type__custom';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment