function _ds_field_ui_clone_view_mode_settings in Display Suite 7.2
Same name and namespace in other branches
- 7 ds.field_ui.inc \_ds_field_ui_clone_view_mode_settings()
Populates display settings for a new view mode from the another view mode.
This is almost a straight copy from Field UI, but with the addition that we can pass the view mode from which we want to clone from.
1 call to _ds_field_ui_clone_view_mode_settings()
- ds_field_ui_layout_clone in includes/
ds.field_ui.inc - Clone a fields layout.
File
- includes/
ds.field_ui.inc, line 946 - Field UI functions for Display Suite.
Code
function _ds_field_ui_clone_view_mode_settings($entity_type, $bundle, $view_mode, $copy_view_mode) {
$settings = field_bundle_settings($entity_type, $bundle);
// Update display settings for field instances.
$instances = field_read_instances(array(
'entity_type' => $entity_type,
'bundle' => $bundle,
));
foreach ($instances as $instance) {
// If this field instance has display settings defined for this view mode,
// respect those settings.
if (isset($instance['display'][$copy_view_mode])) {
$instance['display'][$view_mode] = $instance['display'][$copy_view_mode];
field_update_instance($instance);
}
}
// Update display settings for 'extra fields'.
foreach (array_keys($settings['extra_fields']['display']) as $name) {
if (isset($settings['extra_fields']['display'][$name][$copy_view_mode])) {
$settings['extra_fields']['display'][$name][$view_mode] = $settings['extra_fields']['display'][$name][$copy_view_mode];
}
}
// Save the settings.
field_bundle_settings($entity_type, $bundle, $settings);
}