1 view.inc view::init_display($reset = FALSE)

Set the display for this view and initialize the display handler.

File

core/modules/views/includes/view.inc, line 479
Provides the view object type and associated methods.

Class

view
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.

Code

function init_display($reset = FALSE) {
  // The default display is always the first one in the list.
  if (isset($this->current_display)) {
    return TRUE;
  }

  // Instantiate all displays
  foreach (array_keys($this->display) as $id) {
    // Correct for shallow cloning
    // Often we'll have a cloned view so we don't mess up each other's
    // displays, but the clone is pretty shallow and doesn't necessarily
    // clone the displays. We can tell this by looking to see if a handler
    // has already been set; if it has, but $this->current_display is not
    // set, then something is dreadfully wrong.
    if (!empty($this->display[$id]->handler)) {
      $this->display[$id] = clone $this->display[$id];
      unset($this->display[$id]->handler);
    }
    $this->display[$id]->handler = views_get_plugin('display', $this->display[$id]->display_plugin);
    if (!empty($this->display[$id]->handler)) {
      $this->display[$id]->handler->localization_keys = array($id);
      // Initialize the new display handler with data.
      $this->display[$id]->handler->init($this, $this->display[$id]);
      // If this is NOT the default display handler, let it know which is
      // since it may well utilize some data from the default.
      // This assumes that the 'default' handler is always first. It always
      // is. Make sure of it.
      if ($id != 'default') {
        $this->display[$id]->handler->default_display = &$this->display['default']->handler;
      }
    }
  }

  $this->current_display = 'default';
  $this->display_handler = &$this->display['default']->handler;

  return TRUE;
}