I am trying to change the way comments are displayed in drupal 7 for a specific content type. I am using garland theme. Ideally I would like to modify comment display in my module as opposed to doing it in the theme.
I have successfully implemented hook_form_comment_form_alter to hide the author name this way:
function mymodule_form_comment_form_alter(&$form, &$form_state, $form_id) {
// krumo($form_id);
switch($form_id) {
case 'comment_node_mycontenttype_form':
hide($form['author']);
break;
}
}
Now I would like to alter the comments to:
- Hide the comment title link
- Hide the "reply delete edit" links
I tried to implement hook_comment_view_alter()
and hook_node_alter()
but these seem not to get called. When I use the following code, nothing happens (no krumo outputs and no modifications).
function mymodule_comment_view_alter(&$build) {
krumo($build);
}
function mymodule_node_alter(&$build) {
krumo($build);
hide($build['links']['comment']['#links']['comment-reply']);
}
The only way I found was to modify garland_preprocess_comment()
in template.php in garland theme. But this applies to all content type and also I would like to have all my code in my module.
Is there a proper way to do this?
How come hook_comment_view_alter()
and hook_node_alter()
don't seem to get called?
Note I am using panels to add my content. So I have added the comments and the comment form using panels module. Therefore there is no field to toggle "allow comment title" as there is in structure->content type->comment settings. Even though the "allow comment title" field is unchecked, titles are still displayed. it seems like panels overrides this setting somehow.