1 entity.api.php hook_entity_view_mode_info()

Describe the display modes for entity types.

Display modes let entities be displayed differently depending on the context. For instance, a node can be displayed differently on its own page ('full' mode), on the home page or taxonomy listings ('teaser' mode), or in an RSS feed ('rss' mode). Modules taking part in the display of the entity (notably the Field API) can adjust their behavior depending on the requested view mode. An additional 'default' display mode is available for all entity types. This display mode is not intended for actual entity display, but holds default display settings. For each available display mode, administrators can configure whether it should use its own set of field display settings, or just replicate the settings of the 'default' display mode, thus reducing the amount of display configurations to keep track of.

Note: This hook is invoked inside an implementation of hook_entity_info_alter() so care must be taken not to call anything that will result in an additional (and hence recursive) call to entity_get_info().

Return value

array: An associative array of all entity display modes, keyed by the entity type name, and then the display mode name, with the following keys:

  • label: The human-readable name of the display mode.
  • custom_settings: A boolean specifying whether the display mode should by default use its own custom field display settings. If FALSE, entities displayed in this display mode will reuse the 'default' display settings by default (e.g. right after the module exposing the display mode is enabled), but administrators can later use the Field UI to apply custom display settings specific to the display mode.

See also

entity_view_mode_entity_info_alter()

hook_entity_view_mode_info_alter()

Related topics

File

core/modules/entity/entity.api.php, line 474
Hooks provided by the Entity module.

Code

function hook_entity_view_mode_info() {
  $view_modes['user']['full'] = array(
    'label' => t('User account'),
  );
  $view_modes['user']['compact'] = array(
    'label' => t('Compact'),
    'custom_settings' => TRUE,
  );
  return $view_modes;
}