Using 4.6...
I have a node type which is basically a hacked version of page. It's pretty simple stuff. What I was is an opportunity to change the content of the node (that is, the displayed text). 9 times out of 10 the node content will be displayed as normal, but just occasionally, when the right conditions are met, I want to replace the displayed node content with some hard coded text. I don't want to permanently change the text in the node - next time it gets displayed if should show the node's text as normal (unless my conditions are met again).
Looking through the API I found hook_view(), which appears to do what I want. I hacked together an implementation of this function that just changes the $node->body value, and that looks like the answer:
function mod_view(&$node, $teaser = FALSE, $page = FALSE) {
if( condition ) {
$node->body = "Changed content";
}
$node = node_prepare($node, $teaser);
}
However, I'm very new to this, and I'm not sure of the knock on effects of this. Have I found a decent solution, or is there a better way to doing this?