Skip to content

Commit

Permalink
Add an variable for better handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Coufu committed Nov 28, 2017
1 parent 758f707 commit a7be34d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Plugin/views/area/ViewsXPosedFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand All @@ -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;
Expand Down Expand Up @@ -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 .= '<li><a href="' . strtok($_SERVER['REQUEST_URI'], '?') . '" class="filter-cancel"><span class="filter-name">' . $filters[0]['text'] . '</span><span class="visually-hidden">' . $this->t('Clear filter') . '</span></a>';
}
else {
Expand Down

0 comments on commit a7be34d

Please sign in to comment.