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.
When a view has the same path as an entity's default view path shouldn't it then trigger hook_entity_view()? This would resolve problems with other modules, e.g. Metatag, and might be the more correct way of handling it.
Comment | File | Size | Author |
---|---|---|---|
#7 | views-n1809862-7.patch | 990 bytes | DamienMcKenna |
Comments
Comment #1
DamienMcKennaThis adds some code to views_page() to check if the current path matches the defined path for any entities, if so it loads that entity object and then runs module_invoke_all('entity_view') on it. Food for thought.
If this is the correct direction to take I'll be happy to roll a patch for D8, but I'd appreciate some input. Thanks.
Comment #2
dawehnerFor example the == condition looks not interesting. Isn't there a slash missing?
To be honest i really don't know why you actually want to override the entity view page with a view,
this is not recommended and should be better done by panels.
Comment #3
maximpodorov CreditAttribution: maximpodorov commented@dawehner, the main goal is taxonomy term pages which are acceptable only when created by views (IMHO).
Comment #4
DamienMcKennaI added an extra comment that better explains how the path matching magic works.
Comment #5
DamienMcKenna@dawehner: As maximpodorov mentioned, using Views to replace the normal taxonomy term pages is a very common practice, deficiencies in how those are handled are what I'm trying to resolve with this patch.
Comment #6
dawehnerJust for the case of having the possibility to change the behavior it might make more sense to put this into the page display, so you can override and automatically win.
Comment #7
DamienMcKennaPer dawehner's suggestion I moved the logic into views_plugin_display_page->execute().
Comment #8
gabriel.achille CreditAttribution: gabriel.achille commentedThanks!
Work fine for me: I'm using Views to replace the default display of taxonomy term and the "non-triggering" of hook_entity_view() was preventing some context condition to be checked by the module context_entity_field
Step to reproduce:
with the patch: some reaction IS triggered.
Comment #9
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 6 year old patch in #7 to views_plugin_display_page.inc still applied cleanly to the latest views 7.x-3.x-dev and if still applicable needs to be reviewed.