1 view.inc | view::add_display($type = 'page', $title = NULL, $id = NULL) |
Add a new display handler to the view, automatically creating an id.
Parameters
$type: The plugin type from the views plugin data. Defaults to 'page'.
$title: The title of the display; optional, may be filled in from default.
$id: The id to use.
Return value
The key to the display in $view->display, so that the new display: can be located.
File
- core/
modules/ views/ includes/ view.inc, line 2077 - Provides the view object type and associated methods.
Class
Code
function add_display($type = 'page', $title = NULL, $id = NULL) {
if (empty($type)) {
return FALSE;
}
$plugin = views_fetch_plugin_data('display', $type);
if (empty($plugin)) {
$plugin['title'] = t('Broken');
}
if (empty($id)) {
$id = $this->generate_display_id($type);
if ($id !== 'default') {
preg_match("/[0-9]+/", $id, $count);
$count = $count[0];
}
else {
$count = '';
}
if (empty($title)) {
if ($count > 1) {
$title = $plugin['title'] . ' ' . $count;
}
else {
$title = $plugin['title'];
}
}
}
// Create the new display object
$display = new views_display($type, $id, $title);
// Add the new display object to the view.
$this->display[$id] = $display;
return $id;
}