You are here

function views_views_pre_render in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/views.module \views_views_pre_render()

Implements hook_views_pre_render().

File

core/modules/views/views.module, line 57
Primarily Drupal hooks and global API functions to manipulate views.

Code

function views_views_pre_render($view) {

  // If using AJAX, send identifying data about this view.
  if ($view
    ->ajaxEnabled() && empty($view->is_attachment) && empty($view->live_preview)) {
    $view->element['#attached']['drupalSettings']['views'] = array(
      'ajax_path' => \Drupal::url('views.ajax'),
      'ajaxViews' => array(
        'views_dom_id:' . $view->dom_id => array(
          'view_name' => $view->storage
            ->id(),
          'view_display_id' => $view->current_display,
          'view_args' => Html::escape(implode('/', $view->args)),
          'view_path' => Html::escape(Url::fromRoute('<current>')
            ->toString()),
          'view_base_path' => $view
            ->getPath(),
          'view_dom_id' => $view->dom_id,
          // To fit multiple views on a page, the programmer may have
          // overridden the display's pager_element.
          'pager_element' => isset($view->pager) ? $view->pager
            ->getPagerId() : 0,
        ),
      ),
    );
    $view->element['#attached']['library'][] = 'views/views.ajax';
  }
  return $view;
}