BUGFIX: redirect user down to their posted comment if it was not posted via AJAX

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@73016 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Will Rossiter 2009-03-13 03:49:48 +00:00 committed by Sam Minnee
parent 5e5a06d8e9
commit 6b0ab830dd

View File

@ -287,7 +287,16 @@ class PageCommentInterface_Form extends Form {
echo $comment->renderWith('PageCommentInterface_singlecomment');
}
} else {
Director::redirectBack();
// since it is not ajax redirect user down to their comment since it has been posted
// get the pages url off the comments parent ID.
if($comment->ParentID) {
$page = DataObject::get_by_id("Page", $comment->ParentID);
if($page) {
// Redirect to the actual post on the page.
return Director::redirect(Director::baseURL(). $page->URLSegment.'#PageComment_'.$comment->ID);
}
}
return Director::redirectBack(); // worst case, just go back to the page
}
}
}