I want to have a different comment form title for two different node types, eg blog and products. I've tried a few things with box.tpl.php but at the moment, the best I can come up with is to use different comment settings for the two node types: 'Display on separate page' for the blog and 'Display below post or comments' for products. Then add this template.php snippet:

function mytheme_preprocess_box(&$vars, $hook) {
  switch($vars['title']) {
   case 'Post new comment':
    $vars['title'] = t('Write a review');
  break;
   case 'Reply':
    $vars['title'] = t('Post a comment');
  }
}

But let's face it, that's a workaround, to be put it mildly. And it doesn't give me any flexibility, for example, to display the comment form below the blog post as I'd prefer.

Anyone got any ideas?

Comments

aaronzyf’s picture

...............

nelslynn’s picture

Has anyone figured this out?

doublejosh’s picture

+1

doublejosh’s picture

Had to accomplish this with a node_load() in the theme. Bummer, but since it's cached on the page anyway it's not so bad and the theme is kinda appropriate.

// Used to change the comment box titles, etc.
function MYTHEME_preprocess_box(&$vars, $hook) {
  $n = false;
  if ( check_plain(arg(0))=='node' && is_numeric(check_plain(arg(1))) ) {
    $n= node_load( array('nid'=>arg(1)) );
  }
  // Use this to set search box titles, etc.
  switch($vars['title']) {
    case 'Post new comment' :
      switch($n->type) {
        case 'forum' :
          $vars['title'] = t('Reply...');
          break;
        default :
          $vars['title'] = t('Leave a note.');
      }
    break;
  }
}

Definitely a lame point though.

glennr’s picture

Thanks, doublejosh. That works nicely.