I can't find the answer to his anywhere online as of yet. I'm developing a Drupal module for a client website. The custom content type is called bid. I've created one field using cck that is a node reference. The other fields are generated inside the module using hook_form_alter, hook_form_state etc. On the create bid page the cck field loads the nodereference through the url. Example: example.com/node/add/bid/75. How do I access the referenced node inside my .module file where the form is generated? In other words, how do I load the info (nid, user, path, etc.) for the referenced node within my custom .module script? Thanks for your time.
2 Answers
0
votes
1
votes
If you have the ID of the node, you can load it via node_load (check the API documentation, I've linked it for the Drupal 6 version). Basically all that you have to do is to call node load like
$node = node_load($nid);
and $node will contain a fully populated node object after that.
[You can do more complicated things with this call though, for example you can access the different revisions etc.]