0

I've been at this for a few hours now but can't find a good way to solve this.

Basically what i want to achieve is to trough my template.php file completely override the comment modules output of links when displayed on a node teaser.

So i want to remove the "Add New Comment", "2 New Comments", "2 Comments" for example and have it replaced by only one single button saying something like "Comments (2)" instead.

1 Answer 1

4

This specifically answers your question on how to override the comment links. The important part is using the value of $vars['comment_count'] to add the count into your altered link title.

function YOURTHEME_preprocess_node(&$vars) { if(!empty($vars['content']['links']['comment'])){ // Get rid of other comment link with counts $vars['content']['links']['comment']['#links']['comment-comments'] = array(); // Override the title of the add a comment title displaying a count if($vars['comment_count'] > 0) $vars['content']['links']['comment']['#links']['comment-add']['title'] = 'Comments ('.$vars['comment_count'].')'; else $vars['content']['links']['comment']['#links']['comment-add']['title'] = 'Comments'; } } 
0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.