Jump to content

Recommended Posts

Posted

Using the comments module, is there anyway to do a session redirect after the comment has been submitted so that the page reloads and the comment is now on the page (obviously will only apply to comments that are automatically approved, but it would be nice for them to see their comment live and I don't think the user would think to refresh the page.

Posted

Good question. Here's how you can do it. Rather than doing this:

$form = $page->comments->getCommentForm();
$out = $page->comments->render() . $form->render(); 
$comment = $form->getPostedComment(); 
if($comment) {
 $session->redirect($page->url . "#Comment" . $comment->id); // jump to the new comment when page reloads
} else {
 echo $out; 
}

I don't recall if this all needs to be done before any output is sent or not. But if you find that's the case, then you would just have this code before any output starts and save the "echo $out"; for the part where you are outputting comments in your site.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...