Вам нужно создать небольшой модуль со следующими хуками:
/**
* Implements hook_form_alter().
*
* Alter exposed filter form in views
*/
function MODULE_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
if (isset($form['sort_by'])) {
// Combine sort drop-downs into one.
$form['sorting'] = array(
'#type' => 'select',
'#id' => 'sort',
'#title' => $form['sort_by']['#title'],
);
foreach ($form['sort_by']['#options'] as $sort_by_key => $sort_by_title) {
foreach ($form['sort_order']['#options'] as $sort_order_key => $sort_order_title) {
$form['sorting']['#options'][$sort_by_key . '|' . $sort_order_key] = $sort_by_title . ' ' . $sort_order_title;
}
}
// Get default value for combined sort.
$sort_by_keys = array_keys($form['sort_by']['#options']);
$form['sorting']['#default_value'] = $sort_by_keys[0] . '|' . $form['sort_order']['#default_value'];
}
// Explode combined sort field into two values that are appropriate for views.
if (isset($form_state['input']['sorting'])) {
$sorting = explode('|', $form_state['input']['sorting']);
$form_state['input']['sort_by'] = $sorting[0];
$form_state['input']['sort_order'] = $sorting[1];
}
}
/**
* Default preprocess function for all filter forms.
*/
function MODULE_preprocess_views_exposed_form(&$vars) {
$form = &$vars['form'];
// Render new created sort field.
if (isset($form['sorting'])) {
$form['sorting']['#printed'] = FALSE;
$vars['sorting'] = drupal_render($form['sorting']);
// Need to rebuild the submit button.
$form['submit']['#printed'] = FALSE;
$vars['button'] = drupal_render_children($form);
}
}
Затем вам нужно скопировать файл views / theme / views -posed-form.tpl.php в папку вашей темы и заменить виджеты $ sort_by и $ sort_order новыми $ sorting
Найти:
<?php if (!empty($sort_by)): ?>
<div class="views-exposed-widget views-widget-sort-by">
<?php print $sort_by; ?>
</div>
<div class="views-exposed-widget views-widget-sort-order">
<?php print $sort_order; ?>
</div>
<?php endif; ?>
Заменить:
<?php if (!empty($sorting)): ?>
<div class="views-exposed-widget views-widget-sort-by">
<?php print $sorting; ?>
</div>
<?php endif; ?>