Use case: I want a "quicktabs" style view where each "tab" is a view result row. I'm rendering 3 nodes in the main display, and then the 3 node titles in the attachment. Then I have a bit of custom javascript that toggles the visibility of the appropriate node based on the link clicked. This requires the order of the titles in the attachment and the full node displays in the main display to match.
Setup: I have a Views Content Pane display configured in my view, which has an attachment. The attachment is configured to inherit arguments and exposed filters from the parent display. The content pane is configured so that the arguments and exposed filters / sorts can be configured via the panel pane configuration.
Situation: with the above setup, there is no exposed filters form displayed or rendered - the settings come from the panel pane. As a result, there are no $_GET parameters in the url showing what the exposed input values are.
Problem: the parent content pane display receives the exposed input values from the pane configuration, and that display appears correctly. However, the attachment doesn't receive its exposed input values from the parent display - it is still looking at the url for the $_GET parameters, even though it has the correct values in $view->exposed_input (when printed in the "attach_to()" function in plugins/views_plugin_display_attachment.inc). It doesn't have $view->exposed_raw_input or $view->exposed_data set initially, however once get_exposed_input() function is executed all of these 3 variables are set to the default values, not the actual values configured in the panel pane.
This means that the content pane and its attachment are using different exposed filters/sorts, which is causing problems with my "quicktabs" use case as there is a different sort applied to the 2 displays, and so there is a mismatch between the title clicked and node content displayed.
Solution: 2 line patch (see attached) which uses the "exposed_input" as the parent display and calls $view->set_exposed_input(). This prevents the exposed form being submitted again which would result in the default exposed filter/sort settings being used rather than those configured in the panel pane.
| Comment | File | Size | Author |
|---|---|---|---|
| #40 | interdiff_36-40.txt | 744 bytes | meenakshi_j |
| #40 | 2171389-40.patch | 1.19 KB | meenakshi_j |
| #36 | 2171389.patch | 1.19 KB | sam152 |
| #36 | interdiff.txt | 755 bytes | sam152 |
| #25 | attachments_on_views-2171389-23.patch | 858 bytes | mgifford |
Comments
Comment #1
stella commentedFYI, I also tested the above patch with a more "normal" use case - i.e. a page display with an attachment, and it worked as expected.
Comment #4
dawehnerThat is great, thank you! It would be really great if someone else also has a look at (maybe this is me(marking this tab as pinned)).
Comment #5
stella commentedI think the patch is failing because I've created it the wrong way. Will try rerolling tomorrow.
Comment #6
stella commentedFinally got time to do a patch reroll :)
Comment #8
stella commented6: 2171389-6-views_content_panes_attachment_exposed_filters.patch queued for re-testing.
Comment #10
stella commentedNo idea why this patch is failing, trying against latest dev
Comment #11
stella commented6: 2171389-6-views_content_panes_attachment_exposed_filters.patch queued for re-testing.
Comment #12
jenlamptonI'm also having this problem with the latest version of Views for Drupal 7.
My content pane view has an exposed filter for "county" as does the attachment.
Both exposed filters have the filter identifier 'field_county_value'.
Using the exposed filter on pane config (for the content pane) narrows the results of the main (content pane) display, but not the attachment display.
I was able to get the exposed filters on the attachment working by doing two things.
1) unchecking the Allow settings option: Use exposed widgets form as pane configuration
2) setting the "Use panel path" setting to YES
This patch 100% solves my issue. Thanks 1000! :)
Comment #13
fearlsgroove commented** edit ** nevermind
Comment #14
andrewmacpherson commentedJust a note to confirm that the patch from comment 6 still applies cleanly to the recent views-7.x-3.8 release.
Comment #15
jenlampton*edit* just seconding the above :)
Comment #16
kopeboyCan we include it in a release please?
I am not able to display attachments to Content panes from Panels.
EDIT: Actually the attachment displays only AFTER I use the exposed filter (set on the Content pane to which it is attached), but until then it returns no values.
Of course the exposed form is not input required, and I set the attachment to inherit contextual and exposed filter from the Pane (then I placed the exposed form block with Panels on the page, with Inerith path.
SOLVED: Nevermind, it was a problem with CSS (displaying a floated google map).
Comment #17
stella commentedStill applies cleanly to 7.x-3.10 release. I know you're busy (much like myself) but any chance of getting this committed soon? It's been over a year since I contributed the patch and almost a year since marked RTBC.
Comment #19
dawehnerSeems legit.
You know the answer, don't you?
Comment #20
stella commentedAh sure now, it wasn't 2 years :)
Many thanks for committing it though, it's much appreciated.
Comment #21
blasthaus commentedI was getting this PHP notice on a view after upgrading to 7.x-3.11 as a result of this patch.
It seems that if a views attachment has "inherit_exposed_filters" checked and the view to attach to has no exposed filters (like I did by mistake)
then
$this->view->exposed_inputis not even set, hence the notice.Comment #22
daemonchrist commentedI added a patch based on blasthaus's comment to #2481401: Undefined property: view::$exposed_input in views_plugin_display_attachment
Comment #23
jibranComment #24
dawehnerThe patch itself is working perfectly.
I guess we need test coverage if we fix a bug ..
Comment #25
mgiffordRe-submitting the prior patch for the bots to review.
Comment #29
csedax90 commented#25 is working fine
Comment #30
joelpittet@sedex can you put your testing into words or better into an automated test?
Hopefully that will prevent the bug from reoccurring.
Thanks for testing the patch
Comment #34
emclaughlin commentedJust FYI this isn't working on 8.6 for me.
Comment #35
Beau Townsend commentedUsing Drupal 8.7.8 and patch in #25 resolved the issue for me. I tested with a content type and custom entity and was able to have the Attachment inherit exposed filters from both a Page and Block parent. I was able to use a drop-down exposed filter as well as an exposed Geolocation proximity filter.
Comment #36
sam152 commentedI ran into this and had an additional issue: none of the views exposed filters are added as keys to the render caching integration, so the same views attachment rendered with completely different exposed filters was enough to cause incorrectly cached results.
Disabling the direct render caching integration fixed this, while allowing the block to still appear in dynamic page cache.
Still NW for tests and probably an IS update.
Comment #39
kim.pepperComment #40
meenakshi_j commentedFixed the issue.
Comment #45
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Wonder if this is an issue for D10? I have not seen this issue yet
If so could the IS be updated for D10 steps please
Still needs tests also.
Comment #46
init90Comment #48
emerham commentedYes this still an issue with Drupal 10.3
My steps are simple view
Have a node bundle with two fields:
Create a Paged view and expose the filter of the Select list
Create an attachments view display and attach it to the paged view. Exposed the same filter from the paged view with the same identifier
Ensure the Inherit exposed filters is checked
Attempt to filter the paged view and see that the attachments view is not filtered.
If these are the steps that would let this be reproducible then I can update the issue and start working on some tests.
Comment #49
smustgrave commentedComment #50
yannickooHello 👋 I am coming from #2807857: Exposed filters do not appear on attachment display and can confirm that the patch #40 has fixed the issue, thanks for that 💪