From efdb3765536ea651db02dd9322ba0bbb3fb1ad13 Mon Sep 17 00:00:00 2001 From: Darren Oh Date: Mon, 24 Sep 2012 17:21:05 -0400 Subject: [PATCH] Issue #948198 by Darren Oh: Added the option to hide the order menu for exposed sorts. --- plugins/views_plugin_exposed_form.inc | 24 ++++++++++++++++++------ 1 files changed, 18 insertions(+), 6 deletions(-) diff --git a/plugins/views_plugin_exposed_form.inc b/plugins/views_plugin_exposed_form.inc index 833f44b..2e0ad7d 100644 --- a/plugins/views_plugin_exposed_form.inc +++ b/plugins/views_plugin_exposed_form.inc @@ -41,6 +41,7 @@ class views_plugin_exposed_form extends views_plugin { $options['reset_button'] = array('default' => FALSE, 'bool' => TRUE); $options['reset_button_label'] = array('default' => 'Reset', 'translatable' => TRUE); $options['exposed_sorts_label'] = array('default' => 'Sort by', 'translatable' => TRUE); + $options['expose_sort_order'] = array('default' => TRUE, 'bool' => TRUE); $options['sort_asc_label'] = array('default' => 'Asc', 'translatable' => TRUE); $options['sort_desc_label'] = array('default' => 'Desc', 'translatable' => TRUE); $options['autosubmit'] = array('default' => FALSE, 'bool' => TRUE); @@ -84,12 +85,20 @@ class views_plugin_exposed_form extends views_plugin { '#required' => TRUE, ); + $form['expose_sort_order'] = array( + '#type' => 'checkbox', + '#title' => t('Expose sort order'), + '#description' => t('Allow the user to choose the sort order. If sort order is not exposed, the sort criteria settings for each sort will determine its order.'), + '#default_value' => $this->options['expose_sort_order'], + ); + $form['sort_asc_label'] = array( '#type' => 'textfield', '#title' => t('Ascending'), '#description' => t('Text to use when exposed sort is ordered ascending.'), '#default_value' => $this->options['sort_asc_label'], '#required' => TRUE, + '#dependency' => array('edit-exposed-form-options-expose-sort-order' => array(TRUE)), ); $form['sort_desc_label'] = array( @@ -98,6 +107,7 @@ class views_plugin_exposed_form extends views_plugin { '#description' => t('Text to use when exposed sort is ordered descending.'), '#default_value' => $this->options['sort_desc_label'], '#required' => TRUE, + '#dependency' => array('edit-exposed-form-options-expose-sort-order' => array(TRUE)), ); $form['autosubmit'] = array( @@ -231,12 +241,14 @@ class views_plugin_exposed_form extends views_plugin { $form_state['input']['sort_by'] = array_shift($keys); } - $form['sort_order'] = array( - '#type' => 'select', - '#options' => $sort_order, - '#title' => t('Order'), - '#default_value' => $default_sort_order, - ); + if ($this->options['expose_sort_order']) { + $form['sort_order'] = array( + '#type' => 'select', + '#options' => $sort_order, + '#title' => t('Order'), + '#default_value' => $default_sort_order, + ); + } $form['submit']['#weight'] = 10; if (isset($form['reset'])) { $form['reset']['#weight'] = 10; -- 1.7.3.5