I was wondering if its possible to change the "reply" text links in comments & nodes with actuall buttons?

If so, what text do I edit to allow this?

I know I could make each link "look" like a button with CSS, but I'd actually like to replace the text with a clickable image (if possible).

Thanks for the help!

Comments

stevensj2’s picture

This is the worst support ever; I'm tired of asking questions about Drupal and having to wait a week for even a response (I know I posted this yesterday, but I posted another one even longer ago without so much as a reply still).

This is the internet, not the pony express. I appreciate the help when it's offered, but for the success of Drupal I highly recommend quicker support.

I don't know what kind of sites people can wait a week on before knowing of a fix, but I can't do that any more. I'm switching back to Inivision for my forums.

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

-----------------
Josh Stevens
Nautilus7 Design | Tibathon.com - Home of the National Tiburon Meet

crick’s picture

This is the worst support ever; I'm tired of asking questions about Drupal and having to wait a week for even a response (I know I posted this yesterday, but I posted another one even longer ago without so much as a reply still).

This is the internet, not the pony express. I appreciate the help when it's offered, but for the success of Drupal I highly recommend quicker support.

I don't know what kind of sites people can wait a week on before knowing of a fix, but I can't do that any more. I'm switching back to Inivision for my forums.

Why such anger? You act like members are obligated to answering your questions.

Libervisco’s picture

This is exactly what I want to know and I hope someone can enlighten me on that. :)

I know this is an old thread, but why start a new one when this here stands unanswered. I would like to do exactly what Joshuwa is asking about in Drupal 4.7 without having to modify phptemplate.engine or any module, if possible.

Thanks in advance. I know there are great people here that offer their help. Some just aren't lucky enough to get a timely response I suppose, for any reason. If noone tells me this I guess I'll just have to find out on my own. :P

Cheers
Daniel

Libervisco’s picture

Thanks to sime on drupal support IRC channel here is a solution that makes this possible. It's a hack rather, applied to comment.module in Drupal 4.7, but it works. So here's what is to be done if you want your reply, edit and delete links in comments and forum posts to be clickable button images instead:

1.) Open modules/comment.module in your favourite text editor

2) Find this function:

 function comment_links($comment, $return = 1) {
  global $user;

  $links = array();

  // If we are viewing just this comment, we link back to the node.
  if ($return) {
    $links[] = l(t('parent'), comment_node_url(), NULL, NULL, "comment-$comment->cid");
  }

  if (node_comment_mode($comment->nid) == COMMENT_NODE_READ_WRITE) {
    if (user_access('administer comments') && user_access('post comments')) {
      $links[] = l(t('delete'), "comment/delete/$comment->cid");
      $links[] = l(t('edit'), "comment/edit/$comment->cid");
      $links[] = l(t('reply'), "comment/reply/$comment->nid/$comment->cid");
    }
    else if (user_access('post comments')) {
      if (comment_access('edit', $comment)) {
        $links[] = l(t('edit'), "comment/edit/$comment->cid");
      }
      $links[] = l(t('reply'), "comment/reply/$comment->nid/$comment->cid");
    }
    else {
      $links[] = theme('comment_post_forbidden', $comment->nid);
    }
  }

  return $links;
}

3) Now replace that with this hacked version of that function:

 function comment_links($comment, $return = 1) {
  global $user;

  $links = array();

  // If we are viewing just this comment, we link back to the node.
  if ($return) {
    $links[] = l(t('parent'), comment_node_url(), NULL, NULL, "comment-$comment->cid");
  }

  if (node_comment_mode($comment->nid) == COMMENT_NODE_READ_WRITE) {
    if (user_access('administer comments') && user_access('post comments')) {
$links[] = l('<img src="http://path/to/image.png" />',  "comment/delete/$comment->cid",NULL, NULL, NULL, NULL, TRUE);
$links[] = l('<img src="http://path/to/image.png" />',  "comment/edit/$comment->cid",NULL, NULL, NULL, NULL, TRUE);
$links[] = l('<img src="http://path/to/image.png" />',  "comment/reply/$comment->nid/$comment->cid",NULL, NULL, NULL, NULL, TRUE);

    }
    else if (user_access('post comments')) {
      if (comment_access('edit', $comment)) {
        $links[] = l(t('edit'), "comment/edit/$comment->cid");
      }
      $links[] = l(t('reply'), "comment/reply/$comment->nid/$comment->cid");
    }
    else {
      $links[] = theme('comment_post_forbidden', $comment->nid);
    }
  }

  return $links;
}

NOTE: Replace http://path/to/image.png with your image path corresponding to the link (since you'll probably want different images for reply, edit and delete links).

WARNING: Do not include and tags from above. I put them above just to highlight the code for nicer reading.

That's it!

Cheers
Daniel

jaynedarcy’s picture

What if you want to remove the REPLY link? Can the above be modified to do that? I want to force my members to use the comment form to reply to comments instead of replying to a direct comment and then complaining that it doesn't make sense for their comment to show as most recent comment. Btw, I'm using flat list expanded for comments.

jason342’s picture

jaynedarcy, I've been asking the same question as you for weeks, no one seems to know the answer for that.

I too one the REPLY link removed to prevent direct replies.

I hope some one can help.

jeff h’s picture

I think you'll get what you want simply by commenting out (or deleting) the following two lines in Libervisco's hacked function:

$links[] = l('<img src="http://path/to/image.png" />',  "comment/reply/$comment->nid/$comment->cid",NULL, NULL, NULL, NULL, TRUE);
$links[] = l(t('reply'), "comment/reply/$comment->nid/$comment->cid");

In PHP, you can comment out a line by preceding it with two slashes ie //

Hope this helps,
Jeff

aerowalk’s picture

in the function comment_links

change

$links[] = l(t('reply'), "comment/reply/$comment->nid/$comment->cid");

to

$links[] = l(t('reply'), "comment/reply/$comment->nid", array('title' => t('Add a new comment to this page.')), NULL, 'comment_form');

The "reply" button will force your user to make a new comment, instead of replying to a comment

Bunker-1’s picture

comment form reply button:

function phptemplate_comment_form($form) {
	$form['submit']['#theme'] = 'button';
	$form['submit']['#button_type'] = 'image';
	$form['submit']['#attributes'] = array(
		'src' => '/path/to/button.gif', 
			'alt' => t('Search'),
			'class' => 'search_btn'
		);

	return _phptemplate_callback('comment_form', array('form' => $form));
}

Make sure you don't replace the #value, because your comment form won't work anymore. It took me and my co-worker about 2 hours to figure that out.

For all other forms you can use this code:

function phptemplate_contact_mail_page($form) {
	$form['submit'] = array(
		'#type' => 'submit', 
	'#value' => t('Search'), 
	'#theme' => 'button', 
	'#button_type' => 'image', 
	'#attributes' => array(
		'src' => '/path/to/button.gif', 
			'alt' => t('Search'),
			'class' => 'search_btn',
			),
		);
	return _phptemplate_callback('contact_form', array('form' => $form));
}
Bunker-1’s picture

this was a double post. Sorry about that

bassio’s picture

Instead of hacking the comment core, I suggest another solution:

unfortunately the comment_links is not a themeable function (as I last time checked the documentation).

However, the phptemplate passes the variable $links to the comment tpl file, therefore you can always hack the template.php file of your phptemplate theme with _phptemplate_variables function

and alter the $links variable (which holds the html of the links of the comment) to your liking