function field_view_mode_settings

Returns view mode settings in a given bundle.

Parameters

$entity_type: The type of entity; e.g. 'node' or 'user'.

$bundle: The bundle name to return view mode settings for.

Return value

An array keyed by view mode, with the following key/value pairs:

  • status: Boolean specifying whether the view mode uses a dedicated set of display options (TRUE), or the 'default' options (FALSE). Defaults to FALSE.

Related topics

4 calls to field_view_mode_settings()
DisplayOverview::buildForm in drupal/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
Implements \Drupal\Core\Form\FormInterface::buildForm().
DisplayOverview::submitForm in drupal/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
Overrides \Drupal\field_ui\OverviewBase::submitForm().
entity_get_render_display in drupal/core/includes/entity.inc
Returns the entity_display object used to render an entity.
ViewModeAccessCheck::access in drupal/core/modules/field_ui/lib/Drupal/field_ui/Access/ViewModeAccessCheck.php
Checks for access to route.
1 string reference to 'field_view_mode_settings'
field_info_cache_clear in drupal/core/modules/field/field.info.inc
Clears the field info cache without clearing the field data cache.

File

drupal/core/modules/field/field.module, line 630
Attach custom data fields to Drupal entities.

Code

function field_view_mode_settings($entity_type, $bundle) {
  $cache =& drupal_static(__FUNCTION__, array());
  if (!isset($cache[$entity_type][$bundle])) {
    $bundle_settings = field_bundle_settings($entity_type, $bundle);
    $settings = $bundle_settings['view_modes'];

    // Include view modes for which nothing has been stored yet, but whose
    // definition in hook_entity_info_alter() specify they should use custom
    // settings by default.
    $view_modes = entity_get_view_modes($entity_type);
    foreach ($view_modes as $view_mode => $view_mode_info) {
      if (!isset($settings[$view_mode]['status']) && $view_mode_info['status']) {
        $settings[$view_mode]['status'] = TRUE;
      }
    }
    $cache[$entity_type][$bundle] = $settings;
  }
  return $cache[$entity_type][$bundle];
}