Commit 906d2c29 authored by Peacog's avatar Peacog Committed by Mike Keran
Browse files

Issue #2870361 by Peacog: Display exposed sort options as links or radio...

Issue #2870361 by Peacog: Display exposed sort options as links or radio buttons doesn't work if sort order is not exposed
parent 212aca6b
......@@ -150,7 +150,7 @@ class BetterExposedFilters extends InputRequired {
'#type' => 'checkbox',
'#title' => $this->t('Combine sort order with sort by'),
'#default_value' => $existing['sort']['advanced']['combine'],
'#description' => $this->t('Combines the sort by options and order (ascending or decending) into a single list. Use this to display "Option1 (ascending)", "Option1 (descending)", "Option2 (ascending)", "Option2 (descending)" in a single form element.'),
'#description' => $this->t('Combines the sort by options and order (ascending or decending) into a single list. Use this to display "Option1 (ascending)", "Option1 (descending)", "Option2 (ascending)", "Option2 (descending)" in a single form element. Sort order should first be exposed by selecting <strong>Allow people to choose the sort order</strong>.'),
);
$bef_options['sort']['advanced']['combine_rewrite'] = array(
'#type' => 'textarea',
......@@ -624,7 +624,7 @@ Off|No
/*
* Handle exposed sort elements.
*/
if (isset($settings['sort']) && !empty($form['sort_by']) && !empty($form['sort_order'])) {
if (isset($settings['sort']) && !empty($form['sort_by'])) {
$show_apply = TRUE;
// If selected, collect all sort-related form elements and put them
......@@ -634,7 +634,7 @@ Off|No
$sort_elems = array();
// Check for combined sort_by and sort_order.
if ($settings['sort']['advanced']['combine']) {
if ($settings['sort']['advanced']['combine'] && !empty($form['sort_order'])) {
$options = [];
// Add reset sort option at the top of the list.
......@@ -729,19 +729,25 @@ Off|No
}
elseif ('bef_links' == $settings['sort']['bef_format']) {
$form['sort_by']['#theme'] = 'bef_links';
$form['sort_order']['#theme'] = 'bef_links';
if(!empty($form['sort_order'])) {
$form['sort_order']['#theme'] = 'bef_links';
}
// Exposed form displayed as blocks can appear on pages other than the
// view results appear on. This can cause problems with
// select_as_links options as they will use the wrong path. We provide
// a hint for theme functions to correct this.
$form['sort_by']['#bef_path'] = $this->displayHandler->getUrl();
$form['sort_order']['#bef_path'] = $this->displayHandler->getUrl();
if(!empty($form['sort_order'])) {
$form['sort_order']['#bef_path'] = $this->displayHandler->getUrl();
}
}
if ($collapse) {
$sort_elems[] = 'sort_by';
$sort_elems[] = 'sort_order';
if(!empty($form['sort_order'])) {
$sort_elems[] = 'sort_order';
}
}
// Add reset sort option if selected.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment