1

We are using the comments for a particular content type to post reviews for that content type. I have searched the web but can't find a proper solution how to change the text

"Log in or Register to post comments" to something like "Log in or Register to add Review"

only for this one content type. Any suggestions how this can be done, also happy if I can figure out how to hide this for this content type.

I don't believe I can alter comment_links() via template file or custom module (in drupal 7)

Thanks

0

Go through this link will give you a nice work around

https://www.drupal.org/node/170065

Then, you need to change code: Find your modules/comment/comment.module file, open it in a text-editor (like wordpad or the like), and search for the text you don't want to see on pages. You need to comment out (or delete) a bit of code, something like: //

 if (variable_get('user_register', 1)) {
//      return t('<a href="@login">Login</a> or <a href="@register">register</a> to post comments', array('@login' => url('user/login', $destination), '@register' => url('user/register', $destination)));
//    }
//    else {
//      return t('<a href="@login">Login</a> to post comments', array('@login' => url('user/login', $destination)));
//    }
    return '';

The added 'return' is just for case, to ensure nothing to show - I didn't test this.

You can either edit the original file (which is quick but unclean, and requires you to redo the change after every unpgrade), or override that function in your theme properly by placing its copy into your template.php file (whole function!), renaming it to "phptemplate_[name]", and changing as needed. I think (not tested!) that it should look like this (added to 'template.php' in your theme's folder / create the file if not existing yet, with

function phptemplate_comment_post_forbidden($nid) {
  global $user;
  if ($user->uid) {
    return t("you can't post comments");
  }
  else {
    // we cannot use drupal_get_destination() because these links sometimes appear on /node and taxo listing pages
    if (variable_get('comment_form_location', COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
      $destination = "destination=". drupal_urlencode("comment/reply/$nid#comment_form");
    }
    else {
      $destination = "destination=". drupal_urlencode("node/$nid#comment_form");
    }

//    if (variable_get('user_register', 1)) {
//      return t('<a href="@login">Login</a> or <a href="@register">register</a> to post comments', array('@login' => url('user/login', $destination), '@register' => url('user/register', $destination)));
//    }
//    else {
//      return t('<a href="@login">Login</a> to post comments', array('@login' => url('user/login', $destination)));
//    }
    return '';

  }
}

But still, you'll probably need to check on every upgrade, whether this copied code is in sync with core's possible new changes.

0

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