You are here

function social_event_preprocess_node in Open Social 10.1.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_event/social_event.module \social_event_preprocess_node()
  2. 8 modules/social_features/social_event/social_event.module \social_event_preprocess_node()
  3. 8.2 modules/social_features/social_event/social_event.module \social_event_preprocess_node()
  4. 8.3 modules/social_features/social_event/social_event.module \social_event_preprocess_node()
  5. 8.4 modules/social_features/social_event/social_event.module \social_event_preprocess_node()
  6. 8.5 modules/social_features/social_event/social_event.module \social_event_preprocess_node()
  7. 8.6 modules/social_features/social_event/social_event.module \social_event_preprocess_node()
  8. 8.7 modules/social_features/social_event/social_event.module \social_event_preprocess_node()
  9. 8.8 modules/social_features/social_event/social_event.module \social_event_preprocess_node()
  10. 10.3.x modules/social_features/social_event/social_event.module \social_event_preprocess_node()
  11. 10.0.x modules/social_features/social_event/social_event.module \social_event_preprocess_node()
  12. 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 325
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;
      }
    }
  }
}