function view::init_display
3.x view.inc | view::init_display($reset = FALSE) |
2.x view.inc | view::init_display($reset = FALSE) |
Set the display for this view and initialize the display handler.
6 calls to view::init_display()
- view::access in includes/
view.inc - Determine if the given user has access to the view. Note that this sets the display handler if it hasn't been.
- view::build_title in includes/
view.inc - Force the view to build a title.
- view::choose_display in includes/
view.inc - Get the first display that is accessible to the user.
- view::export in includes/
view.inc - Export a view as PHP code.
- view::set_display in includes/
view.inc - Set the display as current.
File
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] = drupal_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)) {
// 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;
}