Hi,

I would need to store the count of words in the node body into the computed field but I do not know which variable should I use to get the content of the node body for calculation.

Thanks a lot.
Petiar.

Comments

Moonshine’s picture

You should be available to get to it via $node->body

Off hand you could probably get away with something like:

$node_field[0]['value'] = count(array_filter(explode(' ', $node->body)));
bwo’s picture

I have the same problem. Unfortunatelly, using $node->body you don't get only content of actual body field, but also of all the fields you enable for display in "display fields" settings. I guess to get only the body field one should use $node->content['body']['#value'], but it doesn't work for me... Does anyone know how I can use this variable in computed field?

mmjvb’s picture

Issue summary: View changes
Status: Active » Closed (outdated)