I have a content type (a) referenced to another content type (b) by url widget, how can I get the ID of the referenced node (b)?

  • In what context do you want the nid ? – Countzero Apr 4 '12 at 14:57
  • i need to get the node id for getting it's fields values and using them in node(a) fields – Abdulrahman Apr 4 '12 at 15:00
  • So you probably want to write a module and implement some custom code in this hook for example. – Countzero Apr 4 '12 at 15:03
  • what function can fulfill (get the nid for referenced node)? – Abdulrahman Apr 4 '12 at 15:08
  • There's no function. You have to retrieve it with your own code from the $build variable. Please read the doc in the page referenced above. – Countzero Apr 4 '12 at 15:25

You can get node id using :

$nid = $node->field_reference['und'][0]['nid'];

And you can check it out from this:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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