function ViewsHooks::viewsPreRender
Implements hook_views_pre_render().
File
-
core/
modules/ views/ src/ Hook/ ViewsHooks.php, line 59
Class
- ViewsHooks
- Hook implementations for views.
Namespace
Drupal\views\HookCode
public function viewsPreRender($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'] = [
'ajax_path' => Url::fromRoute('views.ajax')->toString(),
'ajaxViews' => [
'views_dom_id:' . $view->dom_id => [
'view_name' => $view->storage
->id(),
'view_display_id' => $view->current_display,
'view_args' => Html::escape(implode('/', $view->args)),
'view_path' => Html::escape(\Drupal::service('path.current')->getPath()),
'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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.