I'm talking about strings such as 'Post new comment' or the 'Comments' string itself displayed in the comment form... How will we able to replace these strings such as 'Add Reviews' and 'Reviews' instead? This would be easier if I want the replaced strings to override all the strings in all of the comment forms located in all node types. BUT I only want it take affect on a certain node type and not all.

Comments

halloffame’s picture

I was able to replace the 'Comments' title to 'Reviews' in reviews node type using the ff function:

function phptemplate_comment_wrapper($content, $node) {
  if (!$content || $node->type == 'reviews') {
    return '<div id="comments"><h2 class="comments">'. t('Reviews') .'</h2>'. $content .'</div>';
  }
  else {
    return '<div id="comments"><h2 class="comments">'. t('Comments') .'</h2>'. $content .'</div>';
  }
}

Worked perfectly there.

But I'm still scratching my head over the t('Post new comment') I can't seem to figure the function to set this in per-node type basis.

Please throw in some little light here! Much appreciated.

FanisTsiros’s picture

Aw far as i know you have to make a custom module to alter the $links variable to get it working.

Not sure, i think this post is similar: http://drupal.org/node/352020

ReliabilityConsistencyFeedback

halloffame’s picture

You may be referring to t('Add new comment'). It's different. It turns out that t('Post new comment') is being generated by comment_form_box function and in box.tpl template and its not a $link variable. t('Add new comment') is in comment_link function.

halloffame’s picture

Here's what I have so far:

To replace the h2 $title 'Comments' to 'Reviews' I have this --

<?php
  if (!$content || $node->type == 'reviews') {
    return '<div id="comments"><h2 class="comments">'. t('Reviews') .'</h2>'. $content .'</div>';
  }
?>

To replace the h2 title 'Post a comment' in the comment form to 'Write a review' --

<?php
  if (!$content || $node->type == 'reviews') {
    $content = str_replace(t('Post new comment'), t('Write a review'), $content);
    return ''. $content .'';
 }
?>

Therefore I have this function:

<?php
function phptemplate_comment_wrapper($content, $node) {
  if (!$content || $node->type == 'forum') {
    return '<div id="comments">'. $content .'</div>';
  }
  if (!$content || $node->type == 'reviews') {
    $content = str_replace(t('Post new comment'), t('Write a review'), $content);
    return '<div id="comments"><h2 class="comments">'. t('Reviews') .'</h2>'. $content .'</div>';
  }
  else {
    return '<div id="comments"><h2 class="comments">'. t('Comments') .'</h2>'. $content .'</div>';
  }
}
?>

As for the comment_link I created my own custom module to do just that.

Hope it helps to those who has the same ordeal.

So nice talking to myself (oh thanks FanisTsiros!).

drupalina’s picture

Thanks a LOT! This certainly helps!

But how do I replace teaser strings like "Add new comment" or "1 comment" or "3 comments" with "Add your review", "1 review" "3 reviews" ???

Please help! I could find no answer no matter how much I searched.
Thanks in advance!

itaurus’s picture

Hi,
Please can you help me? can you tell me which files exactly do I have to change to make this work?
Thank You in advance.

richygecko’s picture

Add this function to your template.php file


function phptemplate_preprocess_comment_wrapper(&$vars) {
  if ($vars['content'] && $vars['node']->type == 'forum') {
    $vars['content'] = str_replace('Post new comment', t('Post new reply'), $vars['content']);
  }
}