By danielb on
Hi,
I need to modify the body output of a node, once it has been through the theme functions.
According to this: http://api.drupal.org/api/function/hook_nodeapi/6 I can use the 'alter' op to modify $node->content
So I looked in $node->content and I have a few choices about what I can change. Is it $node->content['body']['#value'] ??
If so then how come this doesn't work :
<?php
function mymodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if ($op == 'alter') {
$node->content['body']['#value'] = "Some random text";
}
}
?>
It doesn't do anything, and the code is definitely getting executed.
Comments
Well yes, $node->content has
Well yes, $node->content has indeed ben rendered, and it has been put into $node->teaser or $node->body depending on which format we are viewing the node in (see http://api.drupal.org/api/function/node_view/6). Slightly confusingly, the relevant one of these is then put into the $content variable available in the node template (see http://api.drupal.org/api/function/template_preprocess_node/6). But anyway, it's $node->teaser or $node->body that you need to manipulate - $node->content is not used again, AFAICS.
gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk