Currently, when posting a comment, the user is redirected to the node itself instead of the comment. Most users would like to see their comment in context after it's posted, and on very busy community sites with other pages, see if anyone has posted since they started writing it.

Therefore I'd like to propose that the behaviour be changed to go to http://example.com/node/123#comment-123 or http://example.com/node/123?page=2#comment-123 for multi-page threads instead of example.com/node/123

Patch forthcoming in the next day or so.

CommentFileSizeAuthor
#1 comment_submit_last_page.patch1.1 KBcatch

Comments

catch’s picture

Status: Active » Needs review
StatusFileSize
new1.1 KB

OK, so as with this patch this code isn't mine, I've just rolled it into a patch against HEAD.

It adds a new function comment_last_page($nid) to comment.module and changes the behaviour of comment_form_submit to display the just posted comment, instead of the original node.

This is working great on my 5.1 install. Not tested against HEAD yet so please review!

dries’s picture

Status: Needs review » Needs work

In various cases, this won't be possible -- for example, when the comment ends up in the moderation queue. From the looks, your patch doesn't take this into account.

catch’s picture

Title: Comment submit should redirect to the comment instead of the node » Comment submit redirect and comment permalinks

No it doesn't and that's a good point - never had comment moderation switched on so it didn't cross my mind.

Here's another idea but it's a bit more serious - permalinks for comments:

If I edit a comment, it takes me to example.com/comment/edit/123 - how about doing the following?

example.com/comment/123 displays the individual comment on it's own page - the comment shows up whether in moderation or not (because moderation isn't access control).

Page also has a breadcrumb back to the parent node.

If the comment is published, then you also get a "view this comment in context" link on that page - due to differing comment display settings this would require Comment links don't work if comment is not present on first page of pager. to be resolved as well.

comment submit redirects to the comment permalink either way - or maybe a switch on moderation settings to go to the "in context" link if moderation is off.

This would allow users to see their comments after they're published, and it'd also mimic the functionality of of some standalone forums in terms of being able to link to and display individual comments.

Caveat, this is beyond my rudimentary php so it's just a suggestion at this point.

xano’s picture

I was just trying to make/find some permalink thing for comments when I encountered this page. Permalinks for nodes can already be made by creating a link to /node/[nid], but this won't work for comments as they're no nodes. It would be cool if they would be created as 'nodes' as well, so one could easily point to /comment/[comment-id]#[comment-id]. In this case Drupal will have to look up to which node the comment is hooked, and load the proper page. The target thing in the url (#[comment-id], I don't exactly know how it's called) and a slight moderation of comment.tpl.php (to create the anchors) will do the rest.

catch’s picture

tenrapid suggested this on http://drupal.org/node/6162#comment-98014

In HEAD this could be better solved by linking to comments like this node/23/comment/34 or node/23/comment/firstnew and then redirect to the correct page. By doing it this way you also get always working permalinks to comments no matter what page the comment is on.

catch’s picture

New module does permalinks for comments:

http://drupal.org/project/comment_page

haven't tried it yet, but in case anyone else finds this issue whilst looking for the same thing.

catch’s picture

Version: 6.x-dev » 7.x-dev
catch’s picture

marking as duplicate of: http://drupal.org/node/177652

catch’s picture

Status: Needs work » Closed (duplicate)
catch’s picture

Version: 7.x-dev » 6.x-dev

http://drupal.org/node/187391 is newer, but leaving this as duplicate.

purabdk’s picture

I solved the issue using following code. you can put following code in your module.

function modulename_form_alter(&$form, $form_state, $form_id) {

if ($form_id == 'comment_form') {
$form['#action'] = request_uri();
$form['#submit'][] = 'noredirect_comment_form_submit';
}
}

/**
* Implementation of hook_comment_form_submit().
*/

function comment_no_redirect_comment_form_submit(&$form, &$form_state) {
$form_state['redirect'] = ltrim($form['#action'], '/');
}