Redirect user to the page which he has just added a new reply
I am using cakePHP and is making a very simple message board.
I came across a question, and I have no idea how to solve it:开发者_开发知识库Let say there were ten records in the Table Reply,
and a user has just successfully made a new reply to the Table. So there are eleven records now. After the new record is made, I use this to redirect the user back to the index:$this->redirect(array('action' => 'index'));
But I am thinking to make the message board more user-friendly by trying to redirect the user back to the reply which he has just added successfully.
Do you have any ideas?
Sure, Cake allows you to do this within your redirect code.
$this->redirect(array('action' => 'reply', $id));
Should probably do it. Note that $id is already populated by Cake, so all you need is the correct view title.
精彩评论