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.
I've noticed that you can't reference the same view in a View area, obviously to prevent infinite loops. I would really really like to reference the same view but with a different display as the No Results Behaviour.
For this to work views would have to make sure that the display that references the other displays is overriding the no results behaviour. Alternatively there could be a setting that allows you to reference the same view with a warning saying that this will cause a WSOD.
Comment | File | Size | Author |
---|---|---|---|
#20 | 1172714.patch | 1.83 KB | dawehner |
#14 | 1172714_14.patch | 615 bytes | mstrelan |
#10 | 1172714.patch | 1.28 KB | dawehner |
#1 | 1172714-Use-the-Global-View-area-to-reference-anothe.patch | 1.27 KB | mstrelan |
Comments
Comment #1
mstrelan CreditAttribution: mstrelan commentedIt looks like the code to detect recursion already exists in the render function so here is a patch that allows you to select a display of the same view.
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedWe could just introduce gating logic and that would take care of the complexity.
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedIt could also deal with the possible ping pong effect.
Comment #4
mstrelan CreditAttribution: mstrelan commentedI'm not sure what you mean, but if you can explain a bit further I might be able to learn a thing or two and roll a patch... otherwise the ball's in your court.
Comment #5
merlinofchaos CreditAttribution: merlinofchaos commentedBy gating logic I mean recursion prevention. Allow any view and any display to be selected, and when building a view, check a variable to see if that view is currently in the process of being built. That would prevent the infinite loop crash issue.
Comment #6
mstrelan CreditAttribution: mstrelan commentedIt looks to me like that is already done...
Comment #7
merlinofchaos CreditAttribution: merlinofchaos commentedThat makes it easy then.
Comment #8
dawehnerThe recursion check is already implemented so this is rtbc.
Comment #9
merlinofchaos CreditAttribution: merlinofchaos commentedPatch doesn't apply now.
Comment #10
dawehnerUpdate patch
Comment #11
dawehnerCommited.
Comment #13
mstrelan CreditAttribution: mstrelan commentedThis is now broken due to #1215602: views_get_views_as_options() for simple use in #options.
See http://drupal.org/node/1215602#comment-5195532
Comment #14
mstrelan CreditAttribution: mstrelan commentedNew patch. Setting to major because it can break existing views if sites are upgraded.
Comment #15
dawehnerI guess that's not the best solution because this would allow you to embed the same display it it's display. So in general views_get_views_as_options has to be fixed.
Comment #16
mstrelan CreditAttribution: mstrelan commentedIf you read the previous comments from when this was initially committed it was agreed that recursion prevention already exists and therefore it is not entirely necessary to prevent users from trying to reference the same display. So essentially views_get_views_as_options has to be fixed only to improve the usability of embedded views in views areas. #1215602: views_get_views_as_options() for simple use in #options has introduced a regression and the fix for it is being blocked on a minor usability issue? I think this patch should be committed to fix the regression and then we can create a new issue to remove the option to embed the same display.
Comment #17
dawehnerWell i see your point, but your patch would add a regression as well: you can now embed the same display of a view to a view, so you have something which you don't want.
Is it so hard to fix another part of the code?
Comment #18
mstrelan CreditAttribution: mstrelan commentedWell you can add it, but views_handler_area_view::render() will prevent it from executing. It would be an edge case as no one who was thinking straight would try to do this.
I guess not, I could say the same thing. I'm not on my development machine at the moment so I've got no Drupal install to test it on. Might take a look some other time.
Comment #19
markie CreditAttribution: markie commentedFYI: This issue has crept up again with the latest release build. Making the line change once again fixes the issue.
Comment #20
dawehnerHere is a different patch which uses all the features of this function. nice!
Just committed it, so people can profit from it.