I've been able to modify node fields from one CCK field to another, but I'm having difficulty getting the Body of the node. I have thousands of existing nodes that use the built-in body field and I don't have the flexibility that I have with CCK fields so I'd like to migrate the data.
I put the following code into the target CCK field but got no joy:

return array(
  0 => array('value' => $node->content['body']['#value']),
);

I think it's because 'body' is actually a string so I've probably got the syntax wrong. Any help would be greatly appreciated. Based on the number of issues surrounding the printing and reading of node->body, I assume that others will find this helpful as well.

Comments

infojunkie’s picture

When VBO executes, the node isn't rendered, so $node->content isn't built. You have the option of building it in the code, but it might be simpler to access the raw body field directly:

return array(
  0 => array('value' => $node->body, 'format' => $node->format), // assuming the CCK field accepts a format as well
);

Does that work better?

dchampine’s picture

That is precisely what I needed! Thanks for your quick reply. It makes perfect sense now that you mention it - you couldn't possibly render every node efficiently so $node->content was a wild goose chase.
Successfully tested it with individual nodes using direct invocation
Successfully completed a run of 700+ with Batch API.
I recommend using this method if you are struggling with existing body description fields in your content types.
Thanks for a great module and support!

infojunkie’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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