Closed (fixed)
Project:
Drupal core
Version:
x.y.z
Component:
node system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Aug 2004 at 22:55 UTC
Updated:
5 Aug 2004 at 02:43 UTC
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.
| Comment | File | Size | Author |
|---|---|---|---|
| testingview.module | 459 bytes | nedjo |
Comments
Comment #1
jonbob commentedWorks 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.
Comment #2
nedjoAhem, you're right, working fine....