function DefaultDisplay::execute
Same name in other branches
- 9 core/modules/views/src/Plugin/views/display/DefaultDisplay.php \Drupal\views\Plugin\views\display\DefaultDisplay::execute()
- 8.9.x core/modules/views/src/Plugin/views/display/DefaultDisplay.php \Drupal\views\Plugin\views\display\DefaultDisplay::execute()
- 10 core/modules/views/src/Plugin/views/display/DefaultDisplay.php \Drupal\views\Plugin\views\display\DefaultDisplay::execute()
The default execute handler fully renders the view.
For the simplest use:
$output = $view->executeDisplay('default', $args);
For more complex usages, a view can be partially built:
$view->setArguments($args);
$view->build('default');
// Build the query
$view->preExecute();
// Pre-execute the query.
$view->execute();
// Run the query
$output = $view->render();
// Render the view
If short circuited at any point, look in $view->build_info for information about the query. After execute, look in $view->result for the array of objects returned from \Drupal::database()->query().
You can also do:
$view->setArguments($args);
$output = $view->render('default');
// Render the view
This illustrates that render is smart enough to call build and execute if these items have not already been accomplished.
Note that execute also must accomplish other tasks, such as setting page titles, and generating exposed filter data if necessary.
Overrides DisplayPluginBase::execute
File
-
core/
modules/ views/ src/ Plugin/ views/ display/ DefaultDisplay.php, line 69
Class
- DefaultDisplay
- A plugin to handle defaults on a view.
Namespace
Drupal\views\Plugin\views\displayCode
public function execute() {
return $this->view
->render($this->display['id']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.