public function UIkitViewTable::buildSortPost in UIkit Components 8
Same name and namespace in other branches
- 8.3 uikit_views/src/Plugin/views/style/UIkitViewTable.php \Drupal\uikit_views\Plugin\views\style\UIkitViewTable::buildSortPost()
- 8.2 uikit_views/src/Plugin/views/style/UIkitViewTable.php \Drupal\uikit_views\Plugin\views\style\UIkitViewTable::buildSortPost()
Add our actual sort criteria
Overrides StylePluginBase::buildSortPost
File
- uikit_views/
src/ Plugin/ views/ style/ UIkitViewTable.php, line 114
Class
- UIkitViewTable
- Style plugin to render each item in a UIkit Table component.
Namespace
Drupal\uikit_views\Plugin\views\styleCode
public function buildSortPost() {
$query = $this->view
->getRequest()->query;
$order = $query
->get('order');
if (!isset($order)) {
// check for a 'default' clicksort. If there isn't one, exit gracefully.
if (empty($this->options['default'])) {
return;
}
$sort = $this->options['default'];
if (!empty($this->options['info'][$sort]['default_sort_order'])) {
$this->order = $this->options['info'][$sort]['default_sort_order'];
}
else {
$this->order = !empty($this->options['order']) ? $this->options['order'] : 'asc';
}
}
else {
$sort = $order;
// Store the $order for later use.
$request_sort = $query
->get('sort');
$this->order = !empty($request_sort) ? strtolower($request_sort) : 'asc';
}
// If a sort we don't know anything about gets through, exit gracefully.
if (empty($this->view->field[$sort])) {
return;
}
// Ensure $this->order is valid.
if ($this->order != 'asc' && $this->order != 'desc') {
$this->order = 'asc';
}
// Store the $sort for later use.
$this->active = $sort;
// Tell the field to click sort.
$this->view->field[$sort]
->clickSort($this->order);
}