function custom_formatters_ds_entity_variables in Custom Formatters 7.2
Format variables on an entity.
Copied and modified from ds.module#588
Parameters
array $vars: Display suite entity variables array.
1 string reference to 'custom_formatters_ds_entity_variables'
- custom_formatters_theme_registry_alter in includes/
ds.inc - Implements hook_theme_registry_alter().
File
- includes/
ds.inc, line 123 - Display Suite module integration.
Code
function custom_formatters_ds_entity_variables(&$vars) {
if (isset($vars['elements']) && isset($vars['elements']['#bundle']) && ($layout = ds_get_layout($vars['elements']['#entity_type'], $vars['elements']['#bundle'], $vars['elements']['#view_mode']))) {
// Move any preprocess fields to render container.
// Inconsitency in taxonomy term naming.
$object = $vars['elements']['#entity_type'];
if ($vars['elements']['#entity_type'] == 'taxonomy_term') {
$object = 'term';
}
if (isset($vars[$object]->preprocess_fields)) {
$fields = ds_get_fields($object);
$field_values = ds_get_field_settings($object, $vars['elements']['#bundle'], $layout['view_mode']);
foreach ($vars[$object]->preprocess_fields as $field) {
if (isset($field_values[$field]['format']) && strpos($field_values[$field]['format'], 'custom_formatters_') === 0) {
$field_settings = ds_get_field_settings($vars['elements']['#entity_type'], $vars['elements']['#bundle'], $vars['elements']['#view_mode']);
$display = array(
'type' => $field_values[$field]['format'],
'settings' => isset($field_settings[$field]['formatter_settings']) ? $field_settings[$field]['formatter_settings'] : array(),
);
$items = array(
$vars[$field],
);
$element = custom_formatters_field_formatter_view($object, $vars[$object], $fields[$field], array(), language_default('language'), $items, $display);
$vars[$field] = render($element);
}
}
}
}
}