we think it's somewhat confusing to have the words "add new comment" to a forum thread and want to change this works to "reply" just like it shows when someone repsonds to a thread "reply" where do we change this?

Comments

pobster’s picture

Line 223 of the comment module:

$links[] = l(t('add new comment'), "comment/reply/$node->nid", array('title' => t('Share your thoughts and opinions related to this posting.')), NULL, 'comment_form');

Change to:

$links[] = l(t('I like cakes'), "comment/reply/$node->nid", array('title' => t('Share your thoughts and opinions related to this posting.')), NULL, 'comment_form');

Or whatever ;o) Obviously this *will* affect every instance of comments which are on a node, so maybe it's not ideal? But it'll work...

Pobster

sepeck’s picture

Try the local module. See the How to on replacing Drupal terminology for a more future resistent method to do this.

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

kingandy’s picture

Locale is kind of a heavy module if you just want to change one string.
String Overrides is a much lighter way of doing the same thing.

++Andy

yelvington’s picture

Hacking the core is the #1 documented way to go to Drupal hell. Much better to use locale.module, and/or tinker with the links at the presentation template level (which can be restricted by node type).

jjj0923’s picture

I concur - is there a way in the locale.module to test and see if the forums module is the module that's being called to present contact and only do the string replacement for the forums.module?

andre75’s picture

Well, I don't like to install too many modules. I already have far too many running and I can feel the impact.
You can do this inside the node-forum.tpl.php.
I once replaced all liks with phpBB like buttons in 4.6:
http://drupal.org/node/56127
But I didn't do this again for my 4.7 install. I like the text links now I guess.
You can do something similar to rename all the links without affecting other node types.

Andre

-------------------------------------------------
http://www.opentravelinfo.com
http://www.aguntherphotography.com

jjj0923’s picture

thanks - I took a look at the code, but I don't understand what I need to change.
I'm not sure where to start in here:

<?php
  if (!_is_forum()) {
    include('node.tpl.php');
    return;
  }
  $curr_user = user_load(array('uid' => $userid));
  $sig = $curr_user->signature;
?>
<div class="comment forum-comment comment-<?php print $row_class; print $comment->new ? ' comment-new forum-comment-new' : ''; ?>">

  <div class="comment-left">
    <div class="author-name"><?php print $name ?></div>
    <?php print $picture ?>

    <?php if (module_exist('flatforum')): ?>
      <span class="author-posts">
        <?php print t('Posts:') . ' ' . $posts; ?><br />
      </span>
      <span class="author-regdate">
        <?php print t('Joined:') . ' ' . $joined; ?><br />
      </span>
    <?php endif ?>
  </div>

 
  <div class="comment-right">
    <div class="title"><?php print check_plain($comment->subject) ?></div>
    <?php if ($comment->new) : ?>
      <a id="new"></a>
      <span class="new"><?php print $new ?></span>
    <?php endif ?>
    <div class="content">
      <?php print $content ?>
      <?php if ($sig): ?>
        <div class="author-signature">--<br /><?php print check_markup($sig); ?></div>
      <?php endif ?>
      <br class="clear" />
      <div class="links"><?php print $submitted . ' ' . $links ?></div>
    </div>
  </div>

</div>
<br class="clear" />
sepeck’s picture

Local is part of core. Trust us when we say this is the better way. Right now if a Drupal security release came out, you'd have to remember and document and make sure those who came after you remembered and knew how to change the code you are looking for.

Using local module means you don't have to remember. Just do your update like normal. Far far less headache.

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

andre75’s picture

Ah. Hm. In that case use the local module then. No objections.
The code above completely replaces ALL forum links with buttons. I simply copied this stuff from the comment and node modules (I think) and modified it to show buttons instead of text. I only had one reply button ;-) For 4.7 this would most likely have to be changed anyways. I don't think that I had to mess with any of the core modules for this. As I said it was in the template.

As for not changing the code, I completely 100% agree with this. It is what kept me from updating to 4.7 until now. However some changes are completely necessary for me to tailor Drupal to my needs. Fortunately a lot of things can be configured in 4.7 via the admin interface making most of these changes unnecessary.

I usually keep a copy of the original drupal install and just run diff commands on the modules before I update. This way its easy to see what I changed (messed with).

-------------------------------------------------
http://www.opentravelinfo.com
http://www.aguntherphotography.com

tqsenkungu’s picture

Use the directions here: http://drupal.org/node/24593

todd nienkerk’s picture

Creating a custom language is a huge hack. Instead, just edit the array of links before it's rendered!

Put this in your template.php. $type is an optional variable that will allow you to specify the content type in your node.tpl.php file (or node-my_content_type.tpl.php) files. Change $type='page' to $type='my custom text' to customize the output.

function custom_links($links, $type='page') {

  // change the text of some links
  if ($links['comment_add'] != '') {
    $links['comment_add']['title'] = 'Reply to this ' . $type;
  }
  if ($links['comment_reply'] != '') {
    $links['comment_reply']['title'] = 'Reply to this comment';
  }
  if ($links['forward_links'] != '') {
    $links['forward_links']['title'] = 'E-mail this ' . $type . ' to a friend';
  }

  return theme('links', $links, array('class' => 'links inline'));
}

Now you need to call that custom function from your node.tpl.php file. Find this chunk:

  <?php if ($links): ?>
    <div class="links">
      <?php print $links; ?>
    </div>
  <?php endif; ?>

... and replace it with:

<?php if ($node->links) { ?><div class="links"><?php print custom_links($node->links, 'post'); ?></div><?php } ?>

Why did I change $links to $node->links? Because $links is already-rendered HTML. To properly change the text of those links, you need access to the original array of links ($node->links).

Todd Ross Nienkerk
Editor, That Other Paper | Co-founder, Four Kitchen Studios

Todd Ross Nienkerk
CEO, Owner, and Co-Founder
Four Kitchens: Websites made with love. For good.

jiangxijay’s picture

Todd, I like this idea.

However, I must be doing something wrong, because even though "Add new comment" is now the correct custom text, the link goes away; it's just text ...

Also, since the entire template.php code is already enclosed in <?php and ?> in the first code block, they should not be inserted into the template.php file.

todd nienkerk’s picture

Please note that I explain that the last piece of PHP code should be inserted into node.tpl.php, not template.php, so I'm not sure why you think I'm formatting that file incorrectly. (Trust me -- I know how to work with template.php.)

Perhaps it's because adding PHP to these forums requires typing <?php ... ?> to effect PHP markup. I'm not mistakenly adding those tags -- I have to in these forums to display color-coded PHP.

Todd Ross Nienkerk
Editor, That Other Paper | Co-founder, Four Kitchen Studios

Todd Ross Nienkerk
CEO, Owner, and Co-Founder
Four Kitchens: Websites made with love. For good.

jiangxijay’s picture

Thanks, Todd.

I did understand that I needed to remove the php statement from the template.php code snippet, but leave it in the node.tpl.php snippet.

I made the suggestion because I didn't know that <code></code> doesn't work for php code, and I was getting errors when I pasted the code exactly as written.

In any case, I inserted these snippets into those two files in a clean version of Garland and I still don't see the link, so perhaps I have a conflict with some other module that alters that code, too.

Thanks, anyway ...

By the way, using localization to change the string is actually quite simple.

http://drupal.org/node/58030

However, changes to "Add new comment" are not appearing, so I suspect there is a conflict somewhere else.

mark_story’s picture

Using the locale module to solve this didn't seem like an elegant solution, as it requires more modules. This however, is perfect, thanks a bunch.

summit’s picture

Subscribing, greetings, Martijn

dvkd’s picture

Hi pobster,

I need the "Add new commment" link to be displayed at the bottom of the page , i.e after displaying all the comments, Is it possible?

thanks in advance ,
Cheers

JohneeJohnson’s picture

But modifying the core can cause serious problems