问题
$GLOBALS['TSFE']->pageNotFoundAndExit('');
is currently used, but instead I would like to redirect to a page ID.
With the command redirectToUri
, I could find no solution, or didn't work.
Code:
/**
* initialize action show
* @return void
*/
public function initializeShowAction() {
if ($this->request->hasArgument('xxx')) {
if ( $xxx=$this->xxxRepository->findByUid(
intval($this->request->getArgument('xxx'))
) ) {
$this->request->setArgument('xxx',$xxx);
return;
}
}
$GLOBALS['TSFE']->pageNotFoundAndExit('');
}
回答1:
You can build an uri with the following code in your controller:
$uriBuilder = $this->uriBuilder;
$uri = $uriBuilder
->setTargetPageUid($pageUid)
->build();
$this->redirectToUri($uri, 0, 404);
回答2:
In your controller you can use one of the following:
# Internal redirect of request to another controller
$this->forward($actionName, $controllerName, $extensionName, array $arguments);
# External HTTP redirect to another controller
$this->redirect($actionName, $controllerName, $extensionName, array $arguments, $pageUid, $delay = 0, $statusCode = 303);
# Redirect to URI
$this->redirectToURI($uri, $delay=0, $statusCode=303);
# Send HTTP status code
$this->throwStatus($statusCode, $statusMessage, $content);
回答3:
Thank you to everyone. My solution is now:
$pageUid = $this->settings['myflexformsettingpart'];
$uriBuilder = $this->uriBuilder;
$uri = $uriBuilder
->setTargetPageUid($pageUid)
->build();
$this->redirectToURI($uri, $delay=0, $statusCode=303);
回答4:
I use it like this:
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/my/404/';
note that I use the URL that realURL generates.
来源:https://stackoverflow.com/questions/40551408/typo3-extbase-redirect-to-pid