You are here

function Field::click_sort in Views (for Drupal 7) 8.3

Called to determine what to tell the clicksorter.

Overrides FieldPluginBase::click_sort

File

lib/Views/field/Plugin/views/field/Field.php, line 240
Definition of Views\field\Plugin\views\field\Field.

Class

Field
A field that displays fieldapi fields.

Namespace

Views\field\Plugin\views\field

Code

function click_sort($order) {

  // No column selected, can't continue.
  if (empty($this->options['click_sort_column'])) {
    return;
  }
  $this
    ->ensureMyTable();
  $column = _field_sql_storage_columnname($this->definition['field_name'], $this->options['click_sort_column']);
  if (!isset($this->aliases[$column])) {

    // Column is not in query; add a sort on it (without adding the column).
    $this->aliases[$column] = $this->tableAlias . '.' . $column;
  }
  $this->query
    ->add_orderby(NULL, NULL, $order, $this->aliases[$column]);
}