Jump to:
| Project: | Drupal core |
| Version: | x.y.z |
| Component: | node system |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
What I was trying to do:
Trying to wrap a <div> around the entire comment_view section from a module in order to specify that div's id for a javascript dom to generate an alternative comment system that wraps the existing comment system and is configurable as a module.
Initially the issues I ran into were 1) the inability to overload comment_render() on a module level (only apparently possible via phptemplate_comment_view()) and 2) the inability to intercept and modify the output of comment_render() before it gets displayed, from a module.
Eventually, running along the chain of calls to find any place I might be able to hook in, I found node_show() in node.module making an explicit call to comment_render() if it is defined. While this won't throw errors if comments are not turned on, it does not provide any way to hook into the behavior. The only two ways, apparently, available to accomplish my goals would be to clone/patch comment.module so that the comment_render() call hits my function, or to put all the code in the theme.
Ideas regarding ways to solve this:
- Create a hook for additional content to be added to nodes, used something vaguely like:
comment_view_append($node, $teaser = FALSE, $page = FALSE) {
$output = "";
if ($page) {
$output .= comment_render($node);
}
return $output;
}
and make comments first-class citizens (moving single comment view to the view hook) - Allow modules to access a final layer between theme and output where they receive the output of the theme. eg.:
newcomments_theme_comment_view($themed, $comment, $links = '', $visible = 1) {
$themed = "<div id='old-comments'>".$theme."</div>";
}
Comments
#1
That last part should have read:
newcomments_theme_comment_view($themed, $comment, $links = '', $visible = 1) {$themed = "<div id='old-comments'>".$themed."</div>";
}
#2
yes this has been overlooked alas ever since.
#3
Fixed as in http://drupal.org/node/73748.
#4