Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TYPO3 Extbase - redirect to pid

$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('');

}
like image 791
Stigi Avatar asked Nov 11 '16 15:11

Stigi


2 Answers

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);
like image 179
René Pflamm Avatar answered Oct 16 '22 06:10

René Pflamm


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);
like image 26
jokumer Avatar answered Oct 16 '22 04:10

jokumer