I have a function in a module that does:
function mymodule_preprocess_node(&$variables) {
if ($variables['type']=='forum') {
$variables['node']->comment = 1;
}
}which should make the comment form become read-only for the current (forum) node.
Unfortunately, this does not work, the full comment form is rendered. Setting the
$variables['node']->comment = 0;
works, it removes the complete comment form
The line that is causing this discrepancy is line 1050 in the comment.module
if (user_access('post comments') && node_comment_mode($nid) == COMMENT_NODE_READ_WRITE && (variable_get('comment_form_location_'. $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_BELOW) && !$reply) {
more, specifically, it is
node_comment_mode($nid) == COMMENT_NODE_READ_WRITE
The node_comment_mode function does a database-dip, and therefore retrieves the original value, instead of the value that is set in my module.
Changing the said statement to
$node->comment == COMMENT_NODE_READ_WRITE
solves that issue. I guess perhaps checking for the existence of the ->comment property in the line previous line makes sense (and still calling node_comment_mode if it doesn't)
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 460596-allow-comment-mode-override-d6.patch | 1.46 KB | brianV |
Comments
Comment #1
brianV commentedbatje,
Perhaps it is best to do something like:
And then using the $comment_mode variable in place of node_comment_mode($nid) in line 1050.
Thoughts?
Comment #2
brianV commentedCan you test this patch to ensure that it works?
Comment #3
Anonymous (not verified) commentedNo response from OP, closing.