From a7be34df5a0dc41e28714a4c372901652cd6bd56 Mon Sep 17 00:00:00 2001 From: Doug Chan Date: Mon, 27 Nov 2017 22:06:07 -0500 Subject: [PATCH] Add an variable for better handling --- src/Plugin/views/area/ViewsXPosedFilters.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Plugin/views/area/ViewsXPosedFilters.php b/src/Plugin/views/area/ViewsXPosedFilters.php index 20e2eb1..19d8b88 100644 --- a/src/Plugin/views/area/ViewsXPosedFilters.php +++ b/src/Plugin/views/area/ViewsXPosedFilters.php @@ -105,6 +105,7 @@ public function render($empty = FALSE) { // Get the value(s) of the filters. $build_count = 0; + $exposed_count = 0; foreach ($this->exposedInput as $exposed_name => $exposed_value) { // Ignore any query string operators that have no input value. if (empty($this->exposedInput[$exposed_name])) { @@ -116,6 +117,9 @@ public function render($empty = FALSE) { continue; } + // Keep track of how many exposed filters there are. + $exposed_count++; + // Ignore any exposed filters that are not listed by the user. if (!empty($exposed_filters) && array_search($exposed_name, $exposed_filters) === FALSE) { continue; @@ -210,7 +214,7 @@ public function render($empty = FALSE) { } // Return plain URL if there is only 1 filter. - if (count($filters) == 1) { + if ($exposed_count == 1 && count($filters) == 1) { $markup .= '
  • ' . $filters[0]['text'] . '' . $this->t('Clear filter') . ''; } else {