function views_db_object::add_display

3.x view.inc views_db_object::add_display($type = 'page', $title = NULL, $id = NULL)
2.x view.inc views_db_object::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 easily located.

1 call to views_db_object::add_display()
views_db_object::new_display in includes/view.inc
Create a new display and a display handler for it.

File

includes/view.inc, line 1861
view.inc Provides the view object type and associated methods.

Class

views_db_object
Base class for views' database objects.

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)) {
    $title = $plugin['title'];

    $id = $this->generate_display_id($type);
    $count = str_replace($type . '_', '', $id);
    if (empty($title)) {
      $title = $plugin['title'] . ' ' . $count;
    }
  }

  // Create the new display object
  $display = new views_display;
  $display->options($type, $id, $title);

  // Add the new display object to the view.
  $this->display[$id] = $display;
  return $id;
}