1 view.inc view::set_display($display_id = NULL)

Set the display as current.

Parameters

$display_id: The id of the display to mark as current.

File

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

Class

view

Code

function set_display($display_id = NULL) {
  // If we have not already initialized the display, do so. But be careful.
  if (empty($this->current_display)) {
    $this->init_display();

    // If handlers were not initialized, and no argument was sent, set up
    // to the default display.
    if (empty($display_id)) {
      $display_id = 'default';
    }
  }

  $display_id = $this->choose_display($display_id);

  // If no display id sent in and one wasn't chosen above, we're finished.
  if (empty($display_id)) {
    return FALSE;
  }

  // Ensure the requested display exists.
  if (empty($this->display[$display_id])) {
    $display_id = 'default';
    if (empty($this->display[$display_id])) {
      watchdog('views', 'set_display() called with invalid display id @display.', array('@display' => $display_id));
      return FALSE;
    }
  }

  // Set the current display.
  $this->current_display = $display_id;

  // Ensure requested display has a working handler.
  if (empty($this->display[$display_id]->handler)) {
    return FALSE;
  }

  // Set a shortcut
  $this->display_handler = &$this->display[$display_id]->handler;

  return TRUE;
}