summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Keran2013-01-18 23:13:21 (GMT)
committer Mike Keran2013-01-18 23:13:21 (GMT)
commit75ca7dcd4106b1c5ead2781dcc26d84efd3e0008 (patch)
tree4e8e6f91bc67c3a7272bcb7c42f1fb50a4fd3f05
parent80db372c7d0cd1335886532a3db21e110569b1da (diff)
Issue #1873164 by mikeker: Fixed Taxonomy exposed filter links not linking to appropriate page.
-rw-r--r--CHANGELOG.txt1
-rw-r--r--better_exposed_filters.theme28
-rw-r--r--better_exposed_filters_exposed_form_plugin.inc34
3 files changed, 55 insertions, 8 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index a6a43aa..130663c 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -13,6 +13,7 @@ By mikeker: Allow rewriting of filter values (similar to the rewrite combined so
Issue #1673562 by buzkall, nedjo: Added Automatically select children in nested checkboxes option.
Issue #1813654 by elbahek, mikeker: Fixed Undefined offset notice on rendered page.
Issue #1627524 by rooby: Added the jQuery slider widget to BEF.
+Issue #1873164 by mikeker: Fixed Taxonomy exposed filter links not linking to appropriate page.
Better Exposed Filters 7.x-3.0-beta2 2012-09-13
------------------------------------------------
diff --git a/better_exposed_filters.theme b/better_exposed_filters.theme
index cfe7200..18ff6e9 100644
--- a/better_exposed_filters.theme
+++ b/better_exposed_filters.theme
@@ -513,6 +513,13 @@ function theme_select_as_links($vars) {
$links = array();
$multiple = !empty($element['#multiple']);
+ // If we're in an exposed block, we'll get passed a path to use for the
+ // Views results page.
+ $path = '';
+ if (!empty($element['#bef_path'])) {
+ $path = $element['#bef_path'];
+ }
+
foreach ($element_set as $key => $value) {
// Custom ID for each link based on the <select>'s original ID.
$id = drupal_html_id($element['#id'] . '-' . $key);
@@ -523,11 +530,11 @@ function theme_select_as_links($vars) {
'#name' => $id,
);
if (array_search($key, $selected_options) === FALSE) {
- $elem['#children'] = l($value, bef_replace_query_string_arg($name, $key, $multiple));
+ $elem['#children'] = l($value, bef_replace_query_string_arg($name, $key, $multiple, FALSE, $path));
$output .= theme('form_element', array('element' => $elem));
}
else {
- $elem['#children'] = l($value, bef_replace_query_string_arg($name, $key, $multiple, TRUE));
+ $elem['#children'] = l($value, bef_replace_query_string_arg($name, $key, $multiple, TRUE, $path));
_form_set_class($elem, array('bef-select-as-links-selected'));
$output .= str_replace('form-item', 'form-item selected', theme('form_element', array('element' => $elem)));
}
@@ -641,15 +648,22 @@ function bef_checkbox($element, $value, $label, $selected) {
* @param string $value
* Query string value.
* @param bool $multiple
- * TRUE if this key/value pair allows multiple values.
+ * (optional) TRUE if this key/value pair allows multiple values.
* @param bool $remove
- * TRUE if this key/value should be a link to remove/unset the filter.
+ * (optional) TRUE if this key/value should be a link to remove/unset the
+ * filter.
+ * @param string $path
+ * (optional) Use this specify the View results page when the exposed form
+ * is displayed as a block and may be a different URL from the results.
+ * Defaults to the current path if unspecified.
*
* @return string
* URL.
*/
-function bef_replace_query_string_arg($key, $value, $multiple = FALSE, $remove = FALSE) {
- $path = arg();
+function bef_replace_query_string_arg($key, $value, $multiple = FALSE, $remove = FALSE, $path = '') {
+ if (!$path) {
+ $path = implode('/', arg());
+ }
// Prevents us from having to check for each index from parse_url that we may
// use.
@@ -676,7 +690,7 @@ function bef_replace_query_string_arg($key, $value, $multiple = FALSE, $remove =
$query[$key] = $value;
}
}
- return url(implode('/', $path), array(
+ return url($path, array(
'query' => $query,
'fragment' => $fragment,
'absolute' => TRUE,
diff --git a/better_exposed_filters_exposed_form_plugin.inc b/better_exposed_filters_exposed_form_plugin.inc
index 4f56ead..103a4c6 100644
--- a/better_exposed_filters_exposed_form_plugin.inc
+++ b/better_exposed_filters_exposed_form_plugin.inc
@@ -621,6 +621,14 @@ Title Desc|Z -> A</pre> Leave the replacement value blank to remove an option al
case 'bef_links':
$form['sort_bef_combine']['#theme'] = 'select_as_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.
+ if ($this->display->display_options['exposed_block']) {
+ $form['sort_bef_combine']['#bef_path'] = $this->display->display_options['path'];
+ }
break;
case 'default':
@@ -667,6 +675,15 @@ Title Desc|Z -> A</pre> Leave the replacement value blank to remove an option al
elseif ('bef_links' == $settings['sort']['bef_format']) {
$form['sort_by']['#theme'] = 'select_as_links';
$form['sort_order']['#theme'] = 'select_as_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.
+ if ($this->display->display_options['exposed_block']) {
+ $form['sort_by']['#bef_path'] = $this->display->display_options['path'];
+ $form['sort_order']['#bef_path'] = $this->display->display_options['path'];
+ }
}
if ($collapse) {
@@ -727,6 +744,14 @@ Title Desc|Z -> A</pre> Leave the replacement value blank to remove an option al
if (count($form['items_per_page']['#options']) > 1) {
$form['items_per_page']['#theme'] = 'select_as_links';
$form['items_per_page']['#items_per_page'] = max($form['items_per_page']['#default_value'], key($form['items_per_page']['#options']));
+
+ // 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.
+ if ($this->display->display_options['exposed_block']) {
+ $form['items_per_page']['#bef_path'] = $this->display->display_options['path'];
+ }
}
break;
}
@@ -970,8 +995,15 @@ Title Desc|Z -> A</pre> Leave the replacement value blank to remove an option al
case 'bef_links':
$show_apply = TRUE;
-
$form[$field_id]['#theme'] = 'select_as_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.
+ if ($this->display->display_options['exposed_block']) {
+ $form[$field_id]['#bef_path'] = $this->display->display_options['path'];
+ }
break;
case 'bef_single':