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

DamienMcKenna’s picture

Project: Panels » Chaos Tool Suite (ctools)
Version: 7.x-3.3 » 7.x-1.x-dev

Moving 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().

DamienMcKenna’s picture

For 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.

DamienMcKenna’s picture

When 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.

DamienMcKenna’s picture

DamienMcKenna’s picture

Status: Active » Closed (duplicate)