[TYPO3-mvc] 404 redirect if requested object doesn't exist? show action
Jochen Rau
jochen.rau at typoplanet.de
Thu Apr 22 12:10:58 CEST 2010
Hi ralph. (Is this you full name ;-) )
On 21.04.10 14:14, ralph wrote:
> hi. i wonder how i can redirect to a 404 page if the requested object
> doesn't exist. like if a post from the blog ws deleted but a website
> visitor calls an old bookmarked link.
> have no clue how to deal with the exeption...
> /**
> * Action that displays one single post
> *
> * @param Tx_BlogExample_Domain_Model_Post $post The post to display
> * @param Tx_BlogExample_Domain_Model_Comment $newComment A new comment
> * @dontvalidate $newComment
> * @return string The rendered view
> */
> public function showAction(Tx_BlogExample_Domain_Model_Post $post,
> Tx_BlogExample_Domain_Model_Comment $newComment = NULL) {
> $this->view->assign('post', $post);
> $this->view->assign('newComment', $newComment);
> }
You might want to pass a status code along with $this->redirect(...). See:
/**
* Forwards the request to another action and / or controller.
*
* NOTE: This method only supports web requests and will thrown an
exception
* if used with other request types.
*
* @param string $actionName Name of the action to forward to
* @param string $controllerName Unqualified object name of the
controller to forward to. If not specified, the current controller is used.
* @param string $extensionName Name of the extension containing the
controller to forward to. If not specified, the current extension is
assumed.
* @param Tx_Extbase_MVC_Controller_Arguments $arguments Arguments to
pass to the target action
* @param integer $pageUid Target page uid. If NULL, the current page
uid is used
* @param integer $delay (optional) The delay in seconds. Default is no
delay.
* @param integer $statusCode (optional) The HTTP status code for the
redirect. Default is "303 See Other"
* @return void
* @throws Tx_Extbase_MVC_Exception_UnsupportedRequestType If the
request is not a web request
* @throws Tx_Extbase_MVC_Exception_StopAction
* @api
*/
protected function redirect($actionName, $controllerName = NULL,
$extensionName = NULL, array $arguments = NULL, $pageUid = NULL, $delay
= 0, $statusCode = 303) {
}
Regards
Jochen
More information about the TYPO3-project-typo3v4mvc
mailing list