Test module for Field UI display modes.
<?php /** * @file * Test module for Field UI display modes. */ /** * Implements hook_theme_registry_alter(). */ function view_mode_test_theme_registry_alter(&$registry) { if ($hooks = state_get('entity_view_mode_theme_output_suggestions', array())) { foreach ($hooks as $hook) { if (isset($registry[$hook])) { $registry[$hook]['function'] = 'view_mode_test_return_suggestions'; } } } } /** * Theme registry callback. */ function view_mode_test_return_suggestions(array $variables) { $suggestions = array(); if (!empty($variables['theme_hook_suggestions'])) { $suggestions = $variables['theme_hook_suggestions']; } if (!empty($variables['theme_hook_suggestion'])) { $suggestions[] = $variables['theme_hook_suggestion']; } return array_reverse($suggestions); } /** * Implements hook_entity_view_mode_info(). */ function view_mode_test_entity_view_mode_info() { $info['node']['info_1'] = array( 'label' => t('Hook-defined display mode #1'), ); $info['node']['info_2'] = array( 'label' => t('Hook-defined display mode #2'), 'custom settings' => FALSE, ); $info['node']['info_3'] = array( 'label' => t('Hook-defined display mode #3'), ); $info['node']['full'] = array( 'label' => t('Full display mode already defined by core.'), 'custom settings' => TRUE, ); $info['taxonomy_term']['info_1'] = array( 'label' => t('Hook-defined display mode #1'), 'custom settings' => TRUE, ); // Invalid entity type. $info['invalid-type']['test'] = array( 'label' => t('Test display mode'), ); // Call entity_get_info() from inside this hook to test recursion prevention. foreach (entity_get_info() as $entity_type => $entity_info) { $info[$entity_type]['recursion'] = array( 'label' => t('Recursion'), ); } return $info; } /** * Implements hook_entity_view_mode_info_alter(). */ function view_mode_test_entity_view_mode_info_alter(&$info) { $info['node']['info_2']['label'] = t('Hook-altered display mode'); $info['node']['info_2']['custom settings'] = TRUE; }