I'm sorry if this is duplicate, but I could not find any issues relating to this topic.

This is pretty straight forward. If I have a hook_node_view in my module, and then override the node view with a panel, then the node hooks are not invoked.

Comments

Status:Active» Closed (works as designed)

hook_node_view() is only invoked when node_view() is invoked. node_view() is only invoked if you include the Node: Content pane which actually views a node.

This isn't really a bug; I would like to find a good way to work around it, but it is not an easy fix.

If you really need this to happen, you can use something like hook_ctools_render_alter() to perform a node view.

Thanks Merlin,

Would it be worth changing this to a feature request?

Thanks,
Patrick

Some modules use node_view for perform other operations (for example fb_graph use this for setup meta tags in node page). Would be nice if this function can be invoked (at least for no lost other modules operations).

hook_node_view() is called when node: content is added as a pane, but unfortunately it would seem it's being called too late (as adding a form to $node->content didn't work.

I really can't seem to find a good method to alter the node object.

hook_ctools_render_alter() won't work for me since the $info['content'] is HTML. If $info['content'] was similar to $node->content, I think I could make it work.

Just one note, make sure that you uncheck "No Extras" or else hook_node_view will not fire.

can be a workaround using hook_ctools_render_alter ,

<?php
function hook_ctools_render_alter(&$info, &$page, &$context) {
  
$data = array_values($context['contexts']);
  
// Below is nothing but to call hook_node_view which force to pass the
   // node object.
  
[module-name]_node_view($data[0]->data, 'full', '');
}
function [
module-name]_node_view($node, $view_mode, $langcode) {
 
// Here we can return a theme e.g.
 
if ($node->type == 'article') {
   
$node->content['somevar'] = $node->field_article_body;
   
// Below will be a custom theme implementation using which we can render
    // any custom template & can implement corresponding preprocess
   
theme([theme-registry-name],array('somevar' => $node));
  }
}
?>