Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This might apply to all relationship filters, but I've only tested it with taxonomy filters via a taxonomy field relationship.
Steps to reproduce:
- Create a new view
- Add a taxonomy term field as a relationship
- Add an exposed filter for the taxonomy term
- Create a page
- Create an attachment
- enable "Inherit exposed filters" setting in attachment and attach to page
- Load page view and filter by taxonomy term
- Attachment doesn't inherit taxonomy filters
I've attached a view that replicates this behavior (it uses the article content type and tags taxonomy).
Comment | File | Size | Author |
---|---|---|---|
#3 | 1026436-3-taxonomy_exposed_filters.patch | 1.37 KB | duellj |
#1 | view_taxonomy_exposed_filters.txt | 6.23 KB | duellj |
view_taxonomy_exposed_filters.txt | 6.69 KB | duellj |
Comments
Comment #1
duellj CreditAttribution: duellj commentedSorry, the relationship was a red herring. Just create a simple page and attachment with a taxonomy term ID filter, and the attachment won't inherit the filter. Attaching new test view with relationship removed.
Comment #2
duellj CreditAttribution: duellj commentedOk, so here's the problem as I can see it:
In views_handler_filter_term_node_tid::accept_exposed_input:
so the filter isn't computed unless $this->validated_exposed_input is set. In views_handler_filer_term_node_tid, validated_exposed_input is only set in exposed_validate:
validated_exposed_input is run only in views_exposed_form_validate for the main page view's exposed form, so it's never run for the attachment.
Comment #3
duellj CreditAttribution: duellj commentedSince the filters are being validated already, could the just the raw input be used for attachment views that inherit exposed input? There might be something I'm missing, but the attached patch let's attached taxonomy filters inherit the values correctly.
Comment #4
merlinofchaos CreditAttribution: merlinofchaos commentedI don't sufficiently understand D7 taxonomy to be able to review this.
Comment #5
merlinofchaos CreditAttribution: merlinofchaos commentedOk, I think I get this now. Committed with a slight change (isset changed to !empty) and not getting rid of the blank line. Needs to be ported to D6.
Comment #6
dawehnerAnd commited.
Comment #8
pinkonomy CreditAttribution: pinkonomy commentedI have the same problem,should I apply the patch from #3 on the Views module?I am using views 7.x-3.3 .Thanks
Comment #9
seattlehimay CreditAttribution: seattlehimay commentedLike #8, I have this problem still.
Filters are not inherited at all (neither text, nor pulldown taxonomy) in my attachment. I am using postgres, if it matters.
Not sure how I can provide useful information for you.
Comment #10
Hanpersand CreditAttribution: Hanpersand commentedSubscribe. This is happening to me in 7.x-3.5.
Comment #11
Hanpersand CreditAttribution: Hanpersand commentedComment #12
nikonvulcano CreditAttribution: nikonvulcano commentedThis is happening to me in 7.x-3.5 whit Taxonomy term filter but ONLY with AUTOCOMPLETE active, while with DROPDOWN MENU it's OK !!
Comment #13
webdrips CreditAttribution: webdrips commentedI have the same problem with autocomplete enabled. There's a somewhat similar bug for taxonomies marked for localization using autocomplete. I wonder if the issue could be related?
I can try to find it and post it if it will be helpful.
Comment #14
FrancescoQ CreditAttribution: FrancescoQ commentedI don't know if it was the same problem, but i fought with exposed filters and attachments today... i discovered that "inherit filters" means "inherit filter values"... so you have to configure the filter section in the same way on the attachment and its main view. In this way worked for me.
Comment #15
redsky CreditAttribution: redsky commentedI thought I'd provide an update since it's been a while.
I'm using views-7.x-3.10 and have this same problem today. I have a page view with an exposed filter criteria. One of those criteria is a taxonomy term. I have an attachment which inherits the filter criteria. When it is setup as autocomplete the attachment displays no results when it is a dropdown it works. It's a large list and an autocomplete would be more appropriate for this use case.
Comment #16
andrew.eatherington@gmail.com CreditAttribution: andrew.eatherington@gmail.com commentedIt looks like #14 FrancescoQ is correct putting the exact same exposed filter on the attachment seems to inherit the values
Comment #17
karan.gshar CreditAttribution: karan.gshar as a volunteer commentedFound the solution:
There are two issues that occur with using autocomplete:
1)If you debug your query in hook_views_query_alter, on initial page load you will find that under 'where' an empty string is being passed to your taxonomy term filter and since filter looks for a tid and an empty string is no 'tid', hence attachment shows up but with no results.
2) If you put a value in your taxonomy term expose filter, then unlike dropdown it takes string as value to check against where clause instead of tid, so you have to convert it into tid.
Here's the example code:
Comment #18
rosemaryreilmanI'm also having a similar issue with views version: 7.x-3.17
I thought it was tied to the main view having ajax enabled. I'm trying
hook_views_query_alter
and while that works when you load the page it does not work on ajax submission.I'm using taxonomy filter, search terms and date fields.