function views_db_object::add_item
Same name in other branches
- 7.x-3.x 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 2255
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;
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;
}