Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When the user cannot create a comment and there are no comments on the node, the comment_wrapper is not called.
In my use case I have to display a request for an anonymous user to register / log in to comment as part of the block rather than in the nodes links as the output has specific requirements by the client.
To achieve this I added the following code to commentsblock_block_view()
if (!$block['content']) {
$block['content'] = theme('comment_wrapper',
array(
'theme_hook_original' => 'comment_wrapper__node_article',
'theme_hook_suggestion' => 'comment_wrapper__node_article',
'content' => array(
'#node' => $node,
'comments' => array(),
),
)
);
}
Then I altered my comment_wrapper.tpl.php file to produce the required markup when $content['comment_form']
was empty.
Comment | File | Size | Author |
---|---|---|---|
#2 | commentsblock-2624298-2.patch | 848 bytes | John Cook |
Comments
Comment #2
John Cook CreditAttribution: John Cook at Curve Agency commentedAdded a patch file for the changes mentioned.