Skip to content

Instantly share code, notes, and snippets.

@mrded
Created October 22, 2013 16:45
Show Gist options
  • Save mrded/7103986 to your computer and use it in GitHub Desktop.
Save mrded/7103986 to your computer and use it in GitHub Desktop.
Drupal: custom entity view modes.
<?php
/**
* Implements hook_entity_info_alter().
*/
function foo_entity_info_alter(&$entity_info) {
$entity_info['node']['view modes']['another_teaser'] = array(
'label' => t('Another teaser'),
'custom settings' => TRUE,
);
}
/**
* Implements hook_preprocess_node().
*/
function foo_preprocess_node(&$vars) {
if ($vars['view_mode'] == 'another_teaser') {
$vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__another_teaser';
}
}
<h1>Hello, Another teaser!</h1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment