Creating custom view modes

Public

mymodule_view_modes.info

Get raw version
text
  1. name = Custom Entity Display Modes
  2. description = Adds additional display modes
  3. core = 7.x

mymodule_view_modes.module

Get raw version
php
  1. <?php
  2. /**
  3.  * Implements hook_entity_info_alter().
  4.  *
  5.  * Adds a new order view mode
  6.  */
  7. function mymodule_view_modes_entity_info_alter(&$entity_info) {
  8. $entity_info['node']['view modes']['custom'] = array(
  9. 'label' => t('Custom Display'),
  10. 'custom settings' => FALSE,
  11. );
  12. }
  13. function mymodule_view_modes_preprocess_node(&$vars) {
  14. if ($vars['node']->type == 'node_type' && $vars['view_mode'] == 'custom') {
  15. $vars['theme_hook_suggestions'][] = 'node__node_type__custom';
  16. }
  17. }