How to call a function when a node is being viewed? Whenever I view a node page, I want to call a function but I'm not sure how to do that.

I was thinking I should use hook_menu() and declare the path as node/%, and attach a callback function to that path. Is that the right way, or is there a correct/better way?
You can implement hook_node_view()


  Act on a node that is being assembled before rendering.


e.g.

function MYMODULE_node_view($node, $view_mode, $langcode) {
  if ($node-&gt;type == 'the_type' &amp;&amp; $view_mode == 'full') {
    // Call your function here.
    my_function($node);
  }
}