function hook_date_formatter_pre_view_alter in Date 7.3
Same name and namespace in other branches
- 8 date.api.php \hook_date_formatter_pre_view_alter()
- 7.2 date.api.php \hook_date_formatter_pre_view_alter()
Alter the entity before formatting it.
Parameters
object $entity: The entity object being viewed.
array $variables: The variables passed to the formatter.
- entity: The $entity object.
- entity_type: The $entity_type.
- field: The $field array.
- instance: The $instance array.
- langcode: The $langcode.
- items: The $items array.
- display: The $display array.
- dates: The processed dates array, empty at this point.
- attributes: The attributes array, empty at this point.
- rdf_mapping: The RDF mapping array.
- add_rdf: If module_exists('rdf').
1 function implements hook_date_formatter_pre_view_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- date_views_date_formatter_pre_view_alter in date_views/
date_views.module - Implements hook_date_formatter_view_alter().
1 invocation of hook_date_formatter_pre_view_alter()
- date_field_formatter_view in ./
date.field.inc - Implements hook_field_formatter_view().
File
- ./
date.api.php, line 43 - Hooks provided by the Date module.
Code
function hook_date_formatter_pre_view_alter(&$entity, array &$variables) {
if (!empty($entity->view)) {
$field = $variables['field'];
$date_id = 'date_id_' . $field['field_name'];
$date_delta = 'date_delta_' . $field['field_name'];
$date_item = $entity->view->result[$entity->view->row_index];
if (!empty($date_item->{$date_id})) {
$entity->date_id = 'date.' . $date_item->{$date_id} . '.' . $field['field_name'] . '.' . $date_item->{$date_delta} . '.0';
}
}
}