1

Could you please advice how to set additional CSS class for the comment block using Drupal hook. I'd like to paint the author and date of the comment with green color if the author of comment is not the author of a node.

Something like

function custom_form_alter(&$form, $form_state, $form_id) {

    if ($author_comment_id !== $author_node_id) {

        $form['#attributes']['class'][] = 'add-class';
    }
}

The problem is that I don't see the #attributes for comment block via dsm ($form). Maybe I'm using the wrong hook? Is there any different way to achive this?

Could you please help?

closed as unclear what you're asking by user10041, Mołot, Krishna Mohan, Scott Joudry, tenken Jun 5 '15 at 15:08

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

1

I would do it by adding a new template for the block. See Drupal 7 Template (Theme Hook) Suggestions

block--[region|[module|--delta]].tpl.php base template: block.tpl.php Theme hook suggestions are made based on these factors, listed from the most specific template to the least. Drupal will use the most specific template it finds:

block--module--delta.tpl.php

block--module.tpl.php

block--region.tpl.php

0

You may use this function template_preprocess_comment

template_preprocess_comment(&$variables)

  • Looks like it's what I need. I'll try. Thanks a lot! – jksport May 26 '15 at 10:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.