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.
While trying to resolve problems with Metatag (#1363476: Panels integration - ensure meta tags work OOTB on entity pages) I've realized that hook_entity_view() never executes on pages that load via Panels (or Panelizer, for that matter). a) is this intentional? b) if so, is it a Panels/Panelizer or CTools issue? c) if so, what's the supported way around it? Thanks.
Comments
Comment #1
DamienMcKennaMoving this over to CTools as I believe it should go there.
So CTool's node_content content type (sic) (plugins/content_types/node_context/node_content.inc) triggers both hook_node_view_alter() and hook_entity_view_alter() on line 128, but does not trigger either hook_entity_view() or hook_node_view().
Reading through some of the code and looking at the different plugins that apply to the scenario of displaying a node, I think page_manager_node_view_page() in node_view.inc should trigger hook_entity_view() and hook_node_view().
Comment #2
DamienMcKennaFor comparison, when you go to node/123 it runs node_show($node) on node 123, which in turn runs node_view_multiple(), which in turn runs entity_prepare_view() and then node_view() on the node. entity_prepare_view() does get executed when the node_content pane is used, but otherwise the Page Manager-driven node view does not trigger it.
Comment #3
DamienMcKennaWhen the node_content pane is added to a Panels/Panelizer output, it ultimately only executes node_view() if there's a 'view' hook named for the node's base type; unfortunately for most content types the base will be "node_content", and as there's no node_content_view() function neither node_view() function nor the hook_node_view or hook_entity_view hooks are executed.
Comment #4
DamienMcKennaRelated: #1760384: Update node_view.inc to execute the normal Drupal hooks
Comment #5
DamienMcKennaAfter talking with merlinofchaos I think it'll be best to close this and focus on the following individual tasks: