You are here

function social_event_preprocess_views_view in Open Social 8.9

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_event/social_event.module \social_event_preprocess_views_view()
  2. 10.0.x modules/social_features/social_event/social_event.module \social_event_preprocess_views_view()
  3. 10.1.x modules/social_features/social_event/social_event.module \social_event_preprocess_views_view()
  4. 10.2.x modules/social_features/social_event/social_event.module \social_event_preprocess_views_view()

Implements template_preprocess_views_view().

File

modules/social_features/social_event/social_event.module, line 933
The Social event module.

Code

function social_event_preprocess_views_view(&$variables) {
  if ($variables['view']
    ->id() === 'event_manage_enrollment_requests') {
    $node_id = \Drupal::routeMatch()
      ->getParameter('node');

    // Implement custom button to go back to the enroll request overview.
    $variables['more'] = [
      '#title' => t('Back to event'),
      '#type' => 'link',
      '#url' => Url::fromRoute('entity.node.canonical', [
        'node' => (int) $node_id,
      ]),
      '#attributes' => [
        'class' => [
          'btn',
          'btn-default',
          'btn-raised',
          'waves-effect',
        ],
      ],
    ];
  }

  // Add a custom cache tag to the user events overview page.
  if ($variables['view']->current_display === 'events_overview' && $variables['view']
    ->id() === 'events') {
    $account_id = \Drupal::routeMatch()
      ->getParameter('user');
    $variables['#cache']['tags'][] = 'event_content_list:user:' . $account_id;
  }
}