Hi guys,
Pls forgive me if this question has already been answered, I did lots of googling, but couldn’t fine anything worth. I am pretty new to Drupal and PHP development (2 months of exp, am basically a Java/J2EE guy). Following is what I am trying to do :
When a url like http://server_name/?q=node/[id] is clicked, I want certain preprocessing task to be done before node content is rendered. I have looked into the node.module source code, and I can see a function node_page_view which renders the node content.
sample code snippet is as follows for your reference :
/**
* Menu callback; view a single node.
*/
function node_page_view($node, $cid = NULL) {
drupal_set_title(check_plain($node->title));
return node_show($node, $cid);
}
One *dirty* way to achieve my goal is to write the custom code in the node_page_view function itself. I am sure it will work but at the cost of compromising with the portability of the application. Not an elegant solution ofcourse :-(
I am sure there must be better way of achieving the same in Drupal.
Appreciate if anyone can help me into this.
P.S. I am working on Drupal 5.x
Thanks for your time
Jameel
Comments
Can I have anybody who can
Can I have anybody who can help me into this pls?
It would help if you
It would help if you explained what you want to do/what your goal is. You may be able to achieve your goal with theming but without more detail on what you want to do it is hard to provide concrete advice
hook_view in your module
I believe that what you need is to implement hook_view in your module. I think that is the place designed to do the things you want to do.
Though hook_view only works
Though hook_view only works if your module "owns" the content type otherwise you could use hook_nodeapi. On the other hand it may be approriate to override node.tpl.php (or a content specific version) depending on the goal