function ViewsUiBaseViewsWizard::build_sorts
Build the part of the form that allows the user to select the sort order.
By default, this adds a "sorted by [date]" filter (when it is available).
1 call to ViewsUiBaseViewsWizard::build_sorts()
- ViewsUiBaseViewsWizard::build_form in plugins/
views_wizard/ views_ui_base_views_wizard.class.php - For AJAX callbacks to build other elements in the "show" form.
File
-
plugins/
views_wizard/ views_ui_base_views_wizard.class.php, line 447
Class
- ViewsUiBaseViewsWizard
- A very generic Views Wizard class - can be constructed for any base table.
Code
protected function build_sorts(&$form, &$form_state) {
$sorts = array(
'none' => t('Unsorted'),
);
// Check if we are allowed to sort by creation date.
if (!empty($this->plugin['created_column'])) {
$sorts += array(
$this->plugin['created_column'] . ':DESC' => t('Newest first'),
$this->plugin['created_column'] . ':ASC' => t('Oldest first'),
);
}
if (isset($this->plugin['available_sorts'])) {
$sorts += $this->plugin['available_sorts'];
}
// If there is no sorts option available continue.
if (!empty($sorts)) {
$form['displays']['show']['sort'] = array(
'#type' => 'select',
'#title' => t('sorted by'),
'#options' => $sorts,
'#default_value' => isset($this->plugin['created_column']) ? $this->plugin['created_column'] . ':DESC' : 'none',
);
}
}