You are here

function views_db_object::add_item in Views (for Drupal 7) 6.2

Same name and namespace in other branches
  1. 6.3 includes/view.inc \views_db_object::add_item()
  2. 7.3 includes/view.inc \views_db_object::add_item()

Add an item with a handler to the view.

These items may be fields, filters, sort criteria, or arguments.

File

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

Class

views_db_object
Base class for views' database objects.

Code

function add_item($display_id, $type, $table, $field, $options = array(), $id = NULL) {
  $types = views_object_types();
  $this
    ->set_display($display_id);
  $fields = $this->display[$display_id]->handler
    ->get_option($types[$type]['plural']);
  if (empty($id)) {
    $count = 0;
    $id = $field;
    while (!empty($fields[$id])) {
      $id = $field . '_' . ++$count;
    }
  }
  $new_item = array(
    'id' => $id,
    'table' => $table,
    'field' => $field,
  ) + $options;
  $handler = views_get_handler($table, $field, $type);
  $fields[$id] = $new_item;
  $this->display[$display_id]->handler
    ->set_option($types[$type]['plural'], $fields);
  return $id;
}