Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I've created a bid module that allows the users to bid on an auction through a node reference. I'm using hook_form_alter() to create the form on the 'create bid' page, and I would like to perform some SQL queries dealing with the referenced node.

How do I load the node reference?

share|improve this question
add comment

1 Answer 1

To load a node, use

node_load($nid);

This requires that the node is saved and that you have it's nid.

To give a better answer more details are needed

share|improve this answer
    
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. –  CarlosM Aug 9 '11 at 21:13
    
If it's part of the path, you can get it from either the menu() hook, or just grabbing it out of $_GET['q'] or arg(#). api.drupal.org/api/drupal/includes--path.inc/function/arg/6 for more info. In this case it would be arg(3) though. –  Jimajamma Dec 12 '11 at 0:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.