onjegolders Posted November 9, 2012 Share Posted November 9, 2012 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. Link to comment Share on other sites More sharing options...
ryan Posted November 12, 2012 Share Posted November 12, 2012 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now