function hook_views_pre_view in Views (for Drupal 7) 8.3
Same name and namespace in other branches
- 6.3 docs/docs.php \hook_views_pre_view()
- 6.2 docs/docs.php \hook_views_pre_view()
- 7.3 views.api.php \hook_views_pre_view()
Alter a view at the very beginning of Views processing.
Output can be added to the view by setting $view->attachment_before and $view->attachment_after.
Parameters
\Drupal\views\ViewExecutable $view: The view object about to be processed.
string $display_id: The machine name of the active display.
array $args: An array of arguments passed into the view.
See also
Related topics
1 invocation of hook_views_pre_view()
- ViewExecutable::preExecute in lib/
Drupal/ views/ ViewExecutable.php - Run attachments and let the display do what it needs to do prior to running.
File
- ./
views.api.php, line 358 - Describes hooks and plugins provided by the Views module.
Code
function hook_views_pre_view(ViewExecutable &$view, &$display_id, array &$args) {
// Change the display if the acting user has 'administer site configuration'
// permission, to display something radically different.
// @todo Note that this is not necessarily the best way to solve that task.
// Add a better example.
if ($view->name == 'my_special_view' && user_access('administer site configuration') && $display_id == 'public_display') {
$display_id = 'private_display';
}
}