Hi,

Im creating a content(node) with 4 fields. One among the field type is computed field. In that, im displaying $node->nid. I mean $display = $node->nid. I hope $node->nid will show the nid of the node.

In my view, im showing the computed field but its coming as empty.

Im using Drupal 6. Can u pls tel wat r d changes i need to do?

Comments

XiaN Vizjereij’s picture

http://drupal.org/node/358306

That helped for me. Simply edit/save every affected node after changing sth. in the computed field.

zmove’s picture

Hmm, I'm not sure the solution listed above are good.

I have the same problem, on the display textarea, the $node object don't seems available, even if you edit and save your node again.

solonim’s picture

I have the same problem. The $node object is available for the "computed code field" but not for the "display format field".
There is a solution to use $node object in display format without put the value in $node_field[0]['value'] in the computed code?

krishnaa’s picture

You can try this,it will work.

Put this code in Display Format field of computed field.

$args = func_get_args();
$node_field_item['value']=$args[0]['#node']->nid;
print $display = $node_field_item['value'];

nicholas.alipaz’s picture

Title: Computed Field is not displaying $node->nid value » $node variable inaccessible to computed fields

Sure #4 works, but this is most certainly a bug. the $node object does not seem to be accessible which completely breaks the functionality needed.

nicholas.alipaz’s picture

Version: 6.x-1.x-dev » 6.x-1.0-beta3

Just to confirm this issue... It is present in beta3. If you go back to beta2 then the $node object becomes accessible again. Someone must have made a "boo boo" on the last version!

giorgio79’s picture

Title: $node variable inaccessible to computed fields » $node variable inaccessible to the Display Format of Computed Fields
Version: 6.x-1.0-beta3 » 6.x-1.x-dev

This still seems to be an issue :)

obrienmd’s picture

Agreed, this is a still an issue!

Pedro Lozano’s picture

Status: Active » Fixed

Actually the node is accesible at $element['#node'].

I've just commited a fix to make it directly available at $node. More intuitive.

Thanks everyone.

nicholas.alipaz’s picture

Thanks Pedro, glad to see this finally fixed. I can finally do an upgrade :p

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.