Same name and namespace in other branches
  1. 6.x-3.x includes/view.inc \views_db_object::add_display()

Add a new display handler to the view, automatically creating an id.

Parameters

string $type: The plugin type from the views plugin data. Defaults to 'page'.

string $title: The title of the display; optional, may be filled in from default.

int $id: The id to use.

Return value

string 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 2396
views_objects Objects that represent a View or part of a view

Class

views_db_object

Code

public 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();
  $display
    ->options($type, $id, $title);

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