I would like to access the title of the node a field belongs to in a field.tpl.php file. My goal is to transform the field into a mailto link that would use the node title as the subject field.
Is it possible to access that information at this point?


You could get the node values from: $element['#object']: The entity to which the field is attached.

So in this case if the field is a node field the $element['#object'] is the node object.

print $element['#object']->title;

Documentation: https://api.drupal.org/api/drupal/modules!field!theme!field.tpl.php/7

| improve this answer | |
  • 1
    Thanks! I just found it meandring around the aptana debugger and the docs. That's just what I was looking for! – Dalmaz Dec 28 '14 at 19:55

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.