Link to home
Start Free TrialLog in
Avatar of accordia
accordia

asked on

How to reference to another node to take values from node

Hi,

I am using hook_nodeapi in Drupal to change some values when op = load. These values are taken from the other content types and replace some text, similiar like tokens do.

But my problem is how to take values from reference field, when op = load. This is important for me because, I need these values to write a query and using them find values for tokens.

I am using this code and it works in other case when op = view

$references = $node->field_reference;
  foreach ($reference as $single_reference) {
    echo 'this is nid '. $single_reference['nid'];
  }

Any help would be appreciated
Avatar of oliverpolden
oliverpolden
Flag of United Kingdom of Great Britain and Northern Ireland image

You want
foreach ($references as $single_reference) {

Note the plural $reference[s].

Also you may find the devel module useful and do:
dpm($node);

Avatar of accordia
accordia

ASKER

Thanks for quick reply!

I made a typing error here, when i try to explain problem, in code I didn't made mistake.

I am using devel module, but there aren't referenced fields in list when $op = 'load'.
ASKER CERTIFIED SOLUTION
Avatar of oliverpolden
oliverpolden
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial