Access one Field from another field via field.tpl.php In Drupal 7, I have two fields field_cta_button and field_cta_text.

I am using field--field-cta-button.tpl.php to modify the outputs of the field.

I need the field_cta_button to change depending on the values of field_cta_text. 

How can I access field_cta_text from field--field-cta-button.tpl.php?

If possible, I would like to do it without installing any extra modules. 


Steps I have tired:

1) Node Load

I have used the following code from this page:

 &lt;?php
$node = node_load($nid);
$field = field_get_items('node', $node, 'field_cta_text');
$output = field_view_value('node', $node, 'field_ctac_text', $field[$delta]);
?&gt;


However, it just outputs this error message:
Notice: Undefined variable: nid in include() (line 60 of /[SITE NAME]/sites/all/themes/legendary/[MY THEME]/field--field-call-to-action.tpl.php).
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7562 of /[SITE NAME]/includes/common.inc).

2) Entity Field Query
I thought I might be able to use EntityFieldQuery(), but I'm not sure how to get it to load the current node.
You can access to the entity (node) to which the field is attached using $element['#object'] variable from the field template (or preprocess function).

For example, add this code in field--field-cta-button.tpl.php:

&lt;?php
$field_cta_text = $element['#object']-&gt;field_cta_text;
echo $field_cta_text[LANGUAGE_NONE][0]['value'];
?&gt;


If you installed devel module you can use dpm($element['#object']) function to inspect the entity variable.