1 view.inc view::add_item($display_id, $type, $table, $field, $options = array(), $id = NULL)

Add an item with a handler to the view.

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

File

core/modules/views/includes/view.inc, line 2204
Provides the view object type and associated methods.

Class

view

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)) {
    $id = $this->generate_item_id($field, $fields);
  }

  $new_item = array(
    'id' => $id,
    'table' => $table,
    'field' => $field,
  ) + $options;

  if (!empty($types[$type]['type'])) {
    $handler_type = $types[$type]['type'];
  }
  else {
    $handler_type = $type;
  }

  $handler = views_get_handler($table, $field, $handler_type);

  $fields[$id] = $new_item;
  $this->display[$display_id]->handler->set_option($types[$type]['plural'], $fields);

  return $id;
}