function social_event_preprocess_node in Open Social 8.9
Same name and namespace in other branches
- 8 modules/social_features/social_event/social_event.module \social_event_preprocess_node()
- 8.2 modules/social_features/social_event/social_event.module \social_event_preprocess_node()
- 8.3 modules/social_features/social_event/social_event.module \social_event_preprocess_node()
- 8.4 modules/social_features/social_event/social_event.module \social_event_preprocess_node()
- 8.5 modules/social_features/social_event/social_event.module \social_event_preprocess_node()
- 8.6 modules/social_features/social_event/social_event.module \social_event_preprocess_node()
- 8.7 modules/social_features/social_event/social_event.module \social_event_preprocess_node()
- 8.8 modules/social_features/social_event/social_event.module \social_event_preprocess_node()
- 10.3.x modules/social_features/social_event/social_event.module \social_event_preprocess_node()
- 10.0.x modules/social_features/social_event/social_event.module \social_event_preprocess_node()
- 10.1.x modules/social_features/social_event/social_event.module \social_event_preprocess_node()
- 10.2.x modules/social_features/social_event/social_event.module \social_event_preprocess_node()
Prepares variables for node templates.
Parameters
array $variables: An associative array containing:
- elements: An array of elements to display in view mode.
- node: The node object.
- view_mode: View mode; e.g., 'full', 'teaser', etc.
File
- modules/
social_features/ social_event/ social_event.module, line 323 - The Social event module.
Code
function social_event_preprocess_node(array &$variables) {
$view_mode = $variables['view_mode'];
$node = $variables['node'];
if ($node
->getType() === 'event') {
$variables['event_date'] = _social_event_format_date($node, $view_mode);
$variables['#cache']['contexts'][] = 'timezone';
if ($view_mode === 'hero') {
// Add Enroll button.
if (empty($variables['event_enrollment'])) {
$form = \Drupal::formBuilder()
->getForm('Drupal\\social_event\\Form\\EnrollActionForm');
$render_array = [
'enroll_action_form' => $form,
];
$variables['event_enrollment'] = $render_array;
}
}
}
}