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
Comment #1
infojunkieWhen 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:Does that work better?
Comment #2
dchampine CreditAttribution: dchampine commentedThat 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!
Comment #3
infojunkie