As noted in the doxygen documentation, the "view" option in the _nodeapi() hook is intended to enable updating of $node settings prior to display:

view": The node is about to be presented to the user.
The module may change $node->body prior to presentation.

However, while the hook is indeed called, it doesn't appear to update the $node->body value; or perhaps I'm merely using it incorrectly. Here is a test module:


function testingview_nodeapi(&$node, $op, $arg = 0) {
  switch ($op) {
    case 'view':
      $node->body .= t("<p>Test worked.</p>");
      drupal_set_message($node->body);
      break;
  }
}

/**
 * Implementation of hook_help().
 */
function testingview_help($section = 'admin/help#taxonomy') {
  switch ($section) {
    case 'admin/modules#description':
      return t('Test of nodeapi "view" option.');
      break;
  }
}

When installed and enabled as a module (see attached file), this test shows that while the hook is indeed called (and so a message is output), no change is made to the $node->body.

I don't immediately see where the hook is called and so am having trouble seeing how to address the issue.

CommentFileSizeAuthor
testingview.module459 bytesnedjo

Comments

jonbob’s picture

Works fine for me. Enabling your model appends a "test worked" paragraph to every node body.

Here's a shot in the dark. Are you looking at a page that's listing node teasers? Those wouldn't be affected by this method; you'd have to change $node->teaser for that.

nedjo’s picture

Ahem, you're right, working fine....