If we are using flat comment view, we should not see a reply link in each comment IMO. Just a reply link on the original post and a comment form at bottom. This might be a core issue.

Comments

hunmonk’s picture

Status: Active » Postponed

i agree, but the current way comment module presents those links makes it basically impossible to alter them. i'm postponing this until we can fix comment module in D7.

aclight’s picture

I haven't looked at D6 much yet so this may not be applicable, but on my D5 site I use flat comments with forums and have removed the reply buttons on each post/comment with this:


function hook_link_alter(&$node, &$links) {
  if (isset($node->type)) {
    switch ($node->type) {
      case 'forum':
        if (array_key_exists('comment_add', $links)) {
          unset($links['comment_add']);
        }
        break;
    }
  }
}

It looks like this should work in D6 if you just reverse the order of the parameters and check for $node->type == project_issue

dww’s picture

Status: Postponed » Active

Looks like a reasonable approach. Seems like this is exactly the sort of thing hook_link_alter() was supposed to be good for. ;)

hunmonk’s picture

@aclight: i tried your solution on a D5 install, and it doesn't work. what it does is remove the 'add new comment' link from the actual node -- it does not remove the 'reply' links from each comment. D6 looks to operate pretty much the same way in this regard.

i fail to see how hook_link_alter() is going to help us here, when it's never invoked for the actual comment links themselves.

i see three options:

  1. roll a patch for D6 to use hook_link_alter w/ comments: i spoke w/ eaton about this, and he expressed reservations -- saying that doing that this late might lead to some unexpected surprises for people using the hook to alter node links.
  2. try to address it in the theming layer: it's doubtful this would be a general solution, unless we can make use of some new crazy theming functionality that i'm not aware of in D6 (maybe that _preprocess thing?). if we can't make use of a general theming solution, then the next possibility would be to just fix it on d.o, in which case we'd need a new issue on infra for that.
  3. we don't do anything now, and address comment module's shortcoming in this area for D7.

so, really, one isn't and option. i'll check w/ some of the theming gurus and see if there does happen to be a general solution we can employ. if not, then this issue should go back to postponed.

i'm pretty sure i've got all the bases covered here, but please let me know if i'm missing anything.

aclight’s picture

@hunmonk--Right, I think there's more to it than just using hook_link_alter(). I did this a few months ago and don't remember the details clearly, but I'll dig around on my site to see exactly what I'm doing.

But it's definitely possible--see, for example, http://www.igorexchange.com/node/355
Note that I've added a "Quote" button to all comments, but I'm pretty sure that button is added by quote.module and is separate from the reply link that's added by comment.module.

Just to be clear, what you're looking to do with this issue is what I've done at the link above, minus the "Quote" button, right?

I know that the reply button at the bottom of the page is added in the theme layer. I'm just not sure where the "reply" links in each comment are removed. I'll look into how I'm doing this and report back, hopefully fairly soon.

aclight’s picture

Hm...bad news

It looks like I'm doing this in comment_links() of comment.module:

// Don't include reply link in comment
//      $links['comment_reply'] = array(
//        'title' => t('reply'),
//        'href' => "comment/reply/$comment->nid/$comment->cid"
//      );

That's going to disable reply links in all comments though, and since d.o uses threaded comments everywhere else, that's not what you want to do.

There are a bunch of issues with comment.module and flat forums. I'll try to find time soon to create a test site using the new dev version of project_issue to see if any of the ones I've run into before will be a problem with IFAC.

Sorry about my original idea here--I forgot that I had patched core to get this to work.

moshe weitzman’s picture

Anyone else think we should move this bug to core and mark critical? It is sucky UI for sure ... I lean towards adding hook_link_alter to comments in some fashion.

hunmonk’s picture

@moshe: i'd love to fix it in core, but eaton's concern that i mentioned in point 1 above is probably a deal-killer.

by quick inspection, it looks like hook_link_alter() is basically designed for node links atm, and it seems awfully late in the cycle to be throwing this kind of curve ball in the mix.

if we really must fix it for d.o, then i'd probably advocate fixing it in the theme layer of the d.o theme for now, and then fixing comment module in D7.

SamRose’s picture

I totally agree with this issue, having the option described above would be awesome. In the mean time I am trying to solve the problem of reasonably overriding without editing core.

I was looking at http://drupal.org/node/44708 which seems to point towards the right direction, along with info in http://api.drupal.org/api/function/theme_links/5

I am trying to understand how this applies directly to the comments reply. I do understand that I would first edit template.php as described at http://drupal.org/node/44708 and then create a file links.tpl.php in theme folder. But, what I am struggling with is what to include in that links.tpl.php file.

How would I tell the template engine to override comment reply link only, in a inks.tpl.php file?

SamRose’s picture

PS. I should add that I am asking this question in the context of Drupal 5.x Any ideas greatly appreciated

langweer’s picture

I would like to do the same, remove reply links from comments in my forum. And I can’t find a solution by overwriting something in my template.php. Does someone have a solution? I do not like to change core files, also seems that to be the only solution at the moment ...

SamRose’s picture

It is possible to overwrite in template.php. When I have a chance, I will come back here and post an example of how I was finally able to do it

zmove’s picture

I think SamRose didn't have chance....

SamRose’s picture

Status: Active » Closed (fixed)

Copy this from "themes.inc" file under "/includes" directory into template.php, place template.php in your theme dir:

/**
 * Return a themed set of links.
 *
 * @param $links
 *   A keyed array of links to be themed.
 * @param $attributes
 *   A keyed array of attributes
 * @return
 *   A string containing an unordered list of links.
 */
function theme_links($links, $attributes = array('class' => 'links')) {
  $output = '';

  if (count($links) > 0) {
    $output = '<ul'. drupal_attributes($attributes) .'>';

    $num_links = count($links);
    $i = 1;

    foreach ($links as $key => $link) {
      $class = '';

This is what needs to be modified to override the comments links in your theme.

dww’s picture

Status: Closed (fixed) » Active

That doesn't fix the problem -- you're just saying "override theme_links()". What we need to close this issue is an implementation of an override for theme_links() that actually removes the links when appropriate.

Zellius’s picture

Can you write a step-by-step explanation? please

SamRose’s picture

dww, I understand that my answer doesn't fix the issue, and accept what you are saying. Can you please elaborate on what you are looking for that *does* fix the issue?

Are you looking for a patch to existing comment.module, or a contribution that does this, or what? I am not clear on what people are looking for here, and would like to help, but want to put my energies in a productive direction. Thanks!

aclight’s picture

@SamRose: What we're looking for is a way to remove the "reply" links in issue comments only (ie. not in comments on the forums, etc.) that doesn't require hacking the core comment module. Your post in comment #14 above does not give a functional override of these reply links that does this. It might be that you didn't copy/paste your code correctly, because it looks like what you pasted there ends abruptly.

So, if you can provide a theme_links() function that removes these reply links on issue comments only, that might be something we could use on d.o. But a patch to the core comment module isn't what we're looking for, because there are reasons (given above in comment #4) why this might not be a good idea.

SamRose’s picture

Ok, makes sense.

pcambra’s picture

The solution I've applied is copying the theme_links to my template.php and rename it as phptemplate_links.
Then, i've added this line before the foreach loop and voilà, all reply links are gone
unset($links['comment_reply']);

aclight’s picture

ajayg’s picture

This is long due issue and due to timing with D6 was not assigned to core. Why not make this a core issue for D7 so we have better way to theme comments?

zbombicz’s picture

My solution is:

function phptemplate_links($links, $attributes = array('class' => 'links')) {
  unset($links['comment_reply']);
  return theme_links($links, $attributes);
}

opinions?

kjarli’s picture

Here is my solution to hide them per node type:

<?php
/**
 * function to overwrite links. removes the reply link per node type
 * 
 * @param $links
 * @param $attributes
 * @return unknown_type
 */
function phptemplate_links($links, $attributes = array('class' => 'links')) {
  // array of node types of which comments should not get the reply link
  $nodes = array('forum', 'blog');
  
  // check if the comment reply link exists
  if (isset($links['comment_reply'])) {
    // it exists, dissect the url location
    // 3th part = node you reply to, 4th part = comment you reply to
    // we need the 3th ($parts[2];)
    $parts = explode('/', $links['comment_reply']['href']);
    
    if (ctype_digit((string) $parts[2])) {
      if (($parent = node_load($parts[2])) && in_array($parent->type, $nodes)) {
        unset($links['comment_reply']);
      }
    }
  }
  
  return theme_links($links, $attributes);
}
?>
phKU’s picture

Following is my easy-light solution for implementing the behavior "allow users to edit their own comments as long as no follow-up replies have been posted". It's easy because it's just a template.php add and light because there's only one database request cached in a static variable.

function [template name]_links($links, $attributes = array('class' => 'links')) {
  
  //  Record all comments of the current node
  static $cur_node_comments = array();

  if (count($links) > 0) {

    // Check if the comment edit link exists
    if (isset($links['comment_edit'])) {
      $cid = substr($links['comment_edit']['href'], 13);
      
      //  Load all comments for the current node if not already done
      if(empty($cur_node_comments)) {
        $query = "SELECT c2.cid, c2.pid FROM `dru_comments` c1 " .
          "INNER JOIN `dru_comments` c2 ON c1.nid = c2.nid " .
          "WHERE c1.cid = %d ORDER BY c2.pid, c2.cid DESC";
        $result = db_query($query, $cid);
        
        //  Builds $cur_node_comments while adding to each comment row an 'edit' allowed flag
        $pid = -1;
        while($row = db_fetch_array($result)) {
          $last = $row[pid] != $pid ? 1 : 0;
          $pid = $row[pid];
          $cur_node_comments[$row[cid]] = $row + array('edit' => $last);
        }
      }
      
      //  Kill unallowed edit link excepted for administer comments rights user
      if(!$cur_node_comments[$cid]['edit'] && !user_access('administer comments'))
        unset($links['comment_edit']);
    }
  }

  return theme_links($links, $attributes);
}

Hope that helps :)

dww’s picture

@phKU: thanks, but that's not really helpful here. ;)

A) That only removes the edit link -- users can still edit comments if they manually type in the right URL themselves.

B) You're trying to solve a completely separate problem than the one described in this issue. What you're talking about is more closely related to #389718: Prevent users from editing their own forum post once there are replies... Everything is so much easier for everyone involved if each issue remains focused on a single change, instead of lumping different features/bugs into the same issue.

Cheers,
-Derek

Rustan’s picture

#24, kjarli: Thanks, very useful.

Bartezz’s picture

#24 works perfectly, thanx!

Oh and as a reminder, clear caches after applying this to template.php as always with changes to the template.php file.
It's monday morning and I forgot, took me 15 minutes before I had the eureka moment :)

Cheers

coolboygfx’s picture

Also phKU's solution is verry useful for removing the edit link from all but last comment.
Thanks for sharing.
But for compatibility reason i suggest to replace `dru_comments` with {comments} in query.

Combining #24 and #25 together in one function is even more powerfull
and in fact, finally comments are starting to behave the way they should:-)

iparsin’s picture

I use "Flat List" to display comments. So, it makes more sense just to disable or remove "reply" link on each comment. My solution is to use hook_link_alter, sorry if I duplicated any of the above comments, it is long and old, so I might miss something, just want to share. I put this code in my custom module call "myfunction".

function myfunction_link_alter(&$links, $node, $comment = NULL) {
	unset($links['comment_reply']);

}

ravurihareesh’s picture

Can we add fields in Comments?

iparsin’s picture

I never did, but believe "Node comments" might be what you are looking for. As it works like full nodes, so you may use cck to add fields and much more. IMO, use with your caution because natively Drupal builds something meant to be nodes, and some don't like "comments" or "users" for better optimization, but definitely we can modify them.

edgar_estor’s picture

thanks kjarli
clear the cache after using the script and DONE.. :)

spyderpie’s picture

I can't seem to get this to work when showing comments in a view.

Any thoughts?

Julie

jaap76’s picture

I'm not to bothered about the reply link, but can someone tell me how I remove the 'login/ register' link from every single comment? Most of my visitors just have a look at my site, but don't have a membership. Thanks.

jaap76’s picture

In fact, I have to correct my request. I would like to have the login/ register link only to be displayed on the first comment below the content. And if a user wants to login from node/33, that the user goes back to node/33 after being logged on. (like it is now, not a custom link that goes to the users profile)

Bartezz’s picture

jaap76’s picture

Thanks for your reply Bartezz.

I've tried this module, but couldn't figure it out. My php skills are not so great.

Bartezz’s picture

@Jaap, search in the issue queue for 'snippets', I'm sure there must be something you can use.

And maybe read up on some basic php skills, helps a lot when you want something else than standard in Drupal, and really isn't that hard to learn as you might think! Don't know the php level you are on now, but maybe this helps; http://www.tizag.com/phpT/

Cheers

jaap76’s picture

Bartezz, I shall bookmark your url. Maybe I can solve the problem myself. Thanks.

dww’s picture

Version: 5.x-2.x-dev » 6.x-1.x-dev
Component: Issues » Comments

Can we please stop using this issue (which has a specific scope and purpose) as a general support forum for comment-related links on your site? ;)

Thanks,
-Derek

klonos’s picture

If the case is still as suggested in the issue summary, we should then either simply make the link take people at the bottom of the page where they can post a new comment or extend it to do something like fill in the comment text area with something like this:

@[user-from-posted-info], <a href="http://drupal.org/node/[current-issue-number]#comment-[comment-number]">#[post-number]</a>:

<blockquote>[comment-text]</blockquote>

For example, if I clicked the reply link from Derek's comment above, then this text area here should be pre-filled with:

@dww, #48:

Can we please stop using this issue (which has a specific scope and purpose) as a general support forum for comment-related links on your site? ;)

Thanks,
-Derek

...this way, all I'd have to do is perhaps clip Derek's comment down to the part I would be interested to quote and finally type my reply and hit the save button. What do you think?

Senpai’s picture

Title: Remove reply links on comments » Remove reply links in flat-threaded comments on drupal.org
Version: 6.x-1.x-dev » 7.x-2.x-dev
Category: bug » feature
Status: Active » Postponed

Regardless of the outcome of this one, its now a D7 issue since we're so close to the drupal.org upgrade re-launch.

Has anyone see the work that's been going on in:

dww’s picture

Title: Remove reply links in flat-threaded comments on drupal.org » Remove reply links in comments on issues

This isn't just about d.o...

dww’s picture

Priority: Minor » Major
Status: Postponed » Active
Issue tags: +project, +drupal.org D7

I just discovered that even if you configure the node type not to display comment threading, core is *always* recording comment threading. Given how we choose to solve #1632492: Figure out and port project_issue comment numbering functionality to D7 this is sort of a big problem now. We definitely don't want people replying to specific comments and introducing threading. It's bad enough that the D6 migration is created comment threads to create the new comments for node revisions (e.g. issue summary updates) so that we don't actually renumber the main D6 issue followup comments. E.g. see http://git7site.devdrupal.org/node/1981038

Based on a quick IRC chat with drumm and tvn, tagging this for the d.o D7 upgrade and bumping priority...

Never a dull moment in d.o upgrade land. :/

drumm’s picture

I committed http://drupalcode.org/project/project_issue.git/commitdiff/0919d58d849f9... to take care of our comment ordering problem. hook_comment_view() is nice because it is invoked before comment_view() tries adding divs. I'd rather have no divs than extra CSS to hide them. The additional node_load() should come straight from the cache and keeps our code clean.

dww’s picture

Assigned: Unassigned » dww

Thanks for that commit, drumm. I've got a fix for the rest of this but I can't get my laptop online right now to push it. I'll push later tonight and reply here to mark this fixed.

Cheers,
-Derek

dww’s picture

Status: Active » Fixed

http://drupalcode.org/project/project_issue.git/commit/c3f99c9

Decided to turn this (and the thing about removing the indentation on threaded comments) into settings so that sites that don't want this behavior can easily turn it off. Just reusing all the nice project behavior specific settings plumbing we've already got from #1569524: Add a 'Project settings' tab on node type edit forms. Although, while I was working on this, I discovered and fixed a bug in how that stuff handled #states:

http://drupalcode.org/project/project.git/commit/64f1457

Anyway, the new settings are now configured how d.o will want them when the default node type is created. Therefore, this will eventually all be fixed automatically once this is merged into bzr and another rebuild happens.

dww’s picture

p.s. Now merged into bzr and should be live on git7site soon (although I can't access that site right now).

Status: Fixed » Closed (fixed)
Issue tags: -project, -drupal.org D7

Automatically closed -- issue fixed for 2 weeks with no activity.