public function ViewExecutable::preview

Preview the given display, with the given arguments.

To be called externally, probably by an AJAX handler of some flavor. Can also be called when views are embedded, as this guarantees normalized output.

This function does not do any access checks on the view. It is the responsibility of the caller to check $view->access() or implement other access logic. To render the view normally with access checks, use views_embed_view() instead.

File

drupal/core/modules/views/lib/Drupal/views/ViewExecutable.php, line 1361
Definition of Drupal\views\ViewExecutable.

Class

ViewExecutable
An object to contain all of the data to generate a view, plus the member functions to build the view query, execute the query and render the output.

Namespace

Drupal\views

Code

public function preview($display_id = NULL, $args = array()) {
  if (empty($this->current_display) || !empty($display_id) && $this->current_display != $display_id) {
    if (!$this
      ->setDisplay($display_id)) {
      return FALSE;
    }
  }
  $this->preview = TRUE;
  $this
    ->preExecute($args);

  // Preview the view.
  $output = $this->display_handler
    ->preview();
  $this
    ->postExecute();
  return $output;
}