1
votes

I have a page that has both a contextual filter and an exposed filter. My Problem lies in the fact that If I access the page through myview/12 (where 12 is my contextual filter) and then use the on-page exposed filter to filter out the result , the value 12 would still be appended to the page and it would limit my results within the contextual filter value... Is there a way to remove the contextual filter value when using an exposed filter?

Thanks!

3

3 Answers

1
votes

You can give a try to the Views Filter Harmonizer module. This module solves the problem when having views with contextual filter and exposed filters at the same tima and you can configure it to make them work independantly.

0
votes

I don't think so. Because the page results is being filtered by the contextual filter before the exposed filters.

Why do you use "myview/12"?! Why don't only use "myview" without anything passed as contextual filter ?

UPDATE: To exclude the contextual filter from the URL, you need to change the the form's redirect attribute by applying hook_form_alter(). To do so you need to follow the following steps:

  1. find the form id.
  2. Change your module weight in "system" table. (Because views' weight defaults to 10, your module needs to have a heavier weight to make sure it affects the form generated by views)
  3. change the the form redirect attribute. $form['#redirect'] = 'myview';

Tell me if it worked.

Muhammad.

0
votes

Provide a validation criteria, that fails if there is some exposed filter in the url, and select to display all values if the validation criteria fails.