Hello,

I would like to suggest the following addition to the nodecomment module (the comments explain why):

450d449
<       break;
452,458d450
<     case 'view':
<       // If this is a comment, redirect to the node it is a comment on.
<       // This is necessary to show the relevant threads when following
<       // a link from (for example) a search result.
<       if (isset($node->comment_target_nid) && arg(0) == 'node' && arg(1) == $node->nid) {
<         drupal_goto("node/". $node->comment_target_nid);
<       }

Comments

crea’s picture

Status: Needs review » Closed (fixed)

D5 branch is not supported anymore. Closing.
Please reopen if the issue is relevant with Nodecomment 6.x-2 branch.

nocean’s picture

Version: 5.x-1.1 » 6.x-2.x-dev
Status: Closed (fixed) » Active

Hi crea, re-opening and re-versioning this feature request. I think this is definitely a relevant issue for 6.x-2 and going forward. Node comments should treat the comment node's location in Drupal relative to the parent thread it is a comment on, and not as an individual content item. I believe the original feature request addresses this, and I think it would be extremely useful, as having users of a site visit a page with a single comment and no context on it is sort of weird.

Update: A quick and (somewhat) dirty work around for this is creating a theme .tpl file for your node comments content type and inserting the following code at the top:

    if (isset($node->comment_target_nid) && arg(0) == 'node' && arg(1) == $node->nid) {
	drupal_goto(url('http://www.yoursite.com/node/' . $node->comment_target_nid . '#comment-' . $node->nid));
}

I wrapped the URL (and hard-coded the domain) in Drupal's url() function to get around some issues with the double encoding of the hash (#) symbol.

You will also need to edit the nodecomments View and change the output so it is wrapped in a DIV with the id comment-[NID]. There are several ways of doing this -- you can either theme the View using additional .tpl files in your theme directory, or as I did, simply use Views filters to modify the generated output, ie:

  1. Edit the nodecomments view.
  2. Click on the "Node: Body" field under the Fields section.
  3. Select the checkbox beside "Rewrite the output of this field".
  4. In the "Text:" box, rewrite the output with something like the following code, and then save the view.
<div id="answer-[nid]">[body]</div>

Then when the comment is accessed directly, it will be auto-redirected to the original content item for that comment, and the fragment (#answer-[NID]) will jump the page to the appropriate comment.

crea’s picture

Some site may want to show comment nodes on individual pages. So if we want to implement it, it should be configurable (per comment type, probably).

michelle’s picture

Definitely needs to be set per content type. Also, don't forget to take paging into account.

Michelle

1kenthomas’s picture

//subscribing.

eidolon night’s picture

+1

crea’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev
crea’s picture

Note that in 3.x we now have nodecomments which also work as "content" i.e. they can have own pages, own comments, etc, etc.
We will redirect to the node page if the nodecomment is not "content".

crea’s picture

Status: Active » Closed (duplicate)