Posted by sokrplare on April 3, 2012 at 9:17pm
I need to use the Commentsblock module, but it is turning out to be pretty buggy. I've got an issue in the queue with a patch for comments not displaying for anonymous users.
Now I've got a second issue posted about how paging is broken, but I'm stumped on how to fix it so wanted to see if anyone else had an idea.
Here is the issue: http://drupal.org/node/1513910
My question is: Is there a way to prevent the comment_node_view function from executing?
Or....should I be going about this an entirely different way (backup plan is to use Views to display comments in a block, but I can't think of a way to respect threading so would like to avoid that if possible).
Comments
I don't know exactly what you
I don't know exactly what you are going for but trying to block comment_node_view is going to some side affects (its part of core). I would create a new node.tpl.php file for your content type. There you can hide the default comment view and use views_embed_view if you want to use views to control how the comments are displayed.
Mike Bosworth
Balanced Scale Media, LLC
balancedscale.com
Pager still gets called
Hmmm...good idea, however I believe comment_node_view will still get called even with a different node.tpl.php file. As it is, the commentsblock module is already unsetting the comments view:
<?php
function commentsblock_node_view($node, $view_mode, $langcode) {
// unset node comments because we render them in our block
unset($node->content['comments']);
...
?>
However, that doesn't prevent it from running and causing the pager issue.
It looks like there might be a solution using hook_module_implementation_alter(). I'll give it a shot and report back!
Fix working!
Thanks to http://drupal.stackexchange.com/a/27406/6581 I've got a patch put in place that seems to work using hook_module_implementation_alter() like so:
<?phpfunction commentsblock_module_implements_alter(&$implementations, $hook) {
if ($hook == 'node_view') {
unset($implementations['comment']);
}
}
?>
Now the only question is what you alluded to, Mike, is unsetting a function in a core module such a good idea? Maybe necessary for this, but I'm concerned about any unintended consequences...
Contrib module that use hook_module_implementation_alter()
A quick search just of contrib module we are using for this (large-ish) site turned up uses of hook_module_implementation_alter by:
Not feeling like that commentsblock module is quite on the same playing field as these practically core "contrib" modules.