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'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
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedhook_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.
Comment #2
pwaterz CreditAttribution: pwaterz commentedThanks Merlin,
Would it be worth changing this to a feature request?
Thanks,
Patrick
Comment #3
dariogcode CreditAttribution: dariogcode commentedSome 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).
Comment #4
webdrips CreditAttribution: webdrips commentedhook_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.
Comment #5
mcpuddin CreditAttribution: mcpuddin commentedJust one note, make sure that you uncheck "No Extras" or else hook_node_view will not fire.
Comment #6
roynilanjan CreditAttribution: roynilanjan commentedcan be a workaround using hook_ctools_render_alter ,
Comment #7
andyg5000When including node_content (add content > node > node content) in panels, be sure to uncheck "No extras
Check here to disable additions that modules might make to the node, such as file attachments and CCK fields; this should just display the basic teaser or body." if you want node_view functions to fire.
For example, I had a rule that displays a help message whenever a node is unpublished. This was not being executed until I unchecked the "No Extras" box.
Comment #8
ehsankhfr CreditAttribution: ehsankhfr commentedTry to duplicate your php code for node_view inside the "PHP Code" inside the "Selection rules". However the logic for this part is based on returning False or True in the "PHP Code" inside the "Selection rules".
For me it worked fine!
Comment #9
ehsankhfr CreditAttribution: ehsankhfr commentedusing module_invoke_all() beside hook_ctools_render_alter is not a good idea in some situations!
Forcing the hooks in Drupal is not really recommended!
Comment #10
roynilanjan CreditAttribution: roynilanjan commented@ehsankhfr: Eventually Drupal executes any hook using *module_invoke_all/module_invoke*(Which is basic architecture of drupal api calls).
Here in the above situation , if we enable *node_view* page of panel , means overriding the basic node view page & it's property and hence *hook_node_view* & any node pre-processor related hooks will not be triggered. So using the basic drupal api call mechanism we can enforce any function as *hook*.
as far #8 seems that we are trying to use PHP filter within panel variant selection rules, as internally PHP *eval* is reponsoble to parse it which is very costly interms of performance & we should try to avoid
Comment #11
ehsankhfr CreditAttribution: ehsankhfr commentedNice recommendation! However, in some situations, I believe using "PHP filter" can not be avoided, Such as: Contextual Filters in views for internal processing of some context for views.
Comment #12
roynilanjan CreditAttribution: roynilanjan commentedIf we have an integration views and panel-page , & integration point is the contextual argument ... which can be easily integrated by *context API of ctools* & expose the token from that which will take care of the argument of view ... and for other any views component we can use the handlers (field,relation,filter etc)
Comment #13
roynilanjan CreditAttribution: roynilanjan commentedhttps://www.drupal.org/files/ctools-n1760384-13-d7.patch fix this problem, FYI that has been merged with current version ctools module.
Technical discussion have found in https://www.drupal.org/node/1760384