function draggableviews_handler_sort::query in DraggableViews 7.2
Called to add the sort to a query.
Overrides views_handler_sort::query
File
- views/
draggableviews_handler_sort.inc, line 12 - Draggableviews views native handler sort.
Class
- draggableviews_handler_sort
- Sort handler for ordering by weight.
Code
function query() {
$this
->ensure_my_table();
// If new items should be placed in the bottom.
if ($this->options['draggableviews_setting_new_items_bottom_list']) {
// New items will get the biggest integer possible instead of NULL.
$field = "COALESCE({$this->table_alias}.{$this->field}, 2147483647)";
$alias = $this->table_alias . '_' . $this->field . '_coalesce';
// No need to call $this->query->add_field(), add_orderby() adds the field.
$this->query
->add_orderby(NULL, $field, $this->options['order'], $alias);
}
else {
// New items will be placed at the top as have NULL value.
$this->query
->add_orderby($this->table_alias, $this->real_field, $this->options['order']);
}
}