1

When creating templates in Drupal 6 I can output just the title for the value of a node reference field like so:

echo $node->field_example[0]['safe']['title'];

I'm trying to do the same thing in Drupal 7 - I've tried many variations like the examples below but the output is always blank or throws an error:

print $content->field_example['und']['0']['node']['title'];

print $content['field_example']['#object']['field_example']['und']['0']['node']['title'];

Any help on how to grab the 'title' value is much appreciated.

2
1
print $field_example[0]['node']->title;

This ended up being the syntax needed to pull just the title from the value of a node reference field.

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.