I just need to output the title of the referanced node into a variable.

According to contemplate you can output it on the node using this:

<div class="field-item"><?php print $node->field_campaign[$node->language][0]['node']->title ?></div>

So i tried to assign it to a variable that i will later pass int a function

$campaign = $node->field_campaign[$node->language][0]['node']->title;

This will not work I get the error:

Notice: Undefined index: node in eval() (line 6 of mysite/sites/all/modules/rules/modules/php.eval.inc(146) : eval()'d code).
Notice: Trying to get property of non-object in eval() (line 6 of mysite/sites/all/modules/rules/modules/php.eval.inc(146) : eval()'d code).

I cant figure out why, can anyone help me?

Thanks

Comments

faqing’s picture

Status: Active » Closed (fixed)

use this code:

$nid = $profile->field_somename['und'][0]['nid']; 
$node = node_load($nid); 
print ($node->title);