1 field.module field_view_mode_settings($entity_type, $bundle)

Returns display mode settings in a given bundle.

Parameters

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

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

Return value

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

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

Related topics

File

core/modules/field/field.module, line 903
Attach custom data fields to Backdrop entities.

Code

function field_view_mode_settings($entity_type, $bundle) {
  $cache = &backdrop_static(__FUNCTION__, array());

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

  return $cache[$entity_type][$bundle];
}