function ds_extras_field_attach_view_alter in Display Suite 7.2
Same name and namespace in other branches
- 7 modules/ds_extras/ds_extras.module \ds_extras_field_attach_view_alter()
Implements hook_field_attach_view_alter().
File
- modules/
ds_extras/ ds_extras.module, line 180 - Display Suite extras main functions.
Code
function ds_extras_field_attach_view_alter(&$build, $context) {
// If views and core doesn't send information along on the entity,
// Display Suite doesn't have a context to render the fields.
if (!isset($build['#entity_type']) && !isset($build['#bundle'])) {
return;
}
$block_data =& drupal_static('ds_block_region');
$region_blocks = variable_get('ds_extras_region_blocks', array());
if (empty($region_blocks)) {
return;
}
$entity_type = $build['#entity_type'];
$bundle = $build['#bundle'];
$view_mode = $context['view_mode'];
$properties = array();
foreach (element_properties($build) as $property) {
$properties[$property] = $build[$property];
}
$properties['#view_mode'] = $view_mode;
if ($layout = ds_get_layout($entity_type, $bundle, $view_mode)) {
foreach ($region_blocks as $block_key => $block) {
if ($block['info'] == "{$entity_type}_{$bundle}_{$view_mode}" && isset($layout['settings']['regions'][$block_key]) && !empty($layout['settings']['regions'][$block_key])) {
foreach ($layout['settings']['regions'][$block_key] as $key => $field) {
if (isset($build[$field])) {
$block_data[$block_key][$field] = $build[$field];
unset($build[$field]);
}
}
if (isset($block_data[$block_key]) && is_array($block_data[$block_key])) {
$block_data[$block_key] += $properties;
if (module_exists('field_group') && !empty($block_data[$block_key]['#fieldgroups'])) {
$block_data[$block_key]['#pre_render'][] = 'field_group_form_pre_render';
}
}
}
}
}
}