4

In my extbase controller action, I want to redirect to another controller/action after a file has been uploaded, so I call

$this->redirect('index', 'Download', null, null, $this->settings['listView']);

Problem is, that the current language parameter gets lost during the redirect. The method signature allows an array of $arguments on the fourth position, but if I put in L there

$this->redirect('index', 'Download', null, array('L' => $GLOBALS['TSFE']->sys_language_uid), $this->settings['listView']);

the redirect wraps this with the extension parameter stuff like

&tx_myext_controller[L]=0

So my question is: How can I add the current language to an extbase redirect?

Michael
  • 2,309
  • 1
  • 23
  • 34

1 Answers1

6

Just quick tip I often use when want to escape the name space of $this->redirect method. I'm using $this->redirectToUri($uri), where $uri is prepared with uriBuilder (which probably is more flexible then common redirect).

$this->uriBuilder->reset()->setArguments(array('L' => $GLOBALS['TSFE']->sys_language_uid))->setTargetPageUid($this->settings['listView']);
$uri = $this->uriBuilder->uriFor('index', array(), 'Download');
$this->redirectToUri($uri);
Michael
  • 2,309
  • 1
  • 23
  • 34
biesior
  • 55,576
  • 10
  • 125
  • 182
  • Works like a charm, but isn't this a bug anyway if I have `L` added to my `config.linkVars` in typoscript. In my opinion the language (or whatever is defined in linkVars) should be added there as well. – Michael Aug 05 '13 at 17:21
  • Hm, weird, I just checked: `config.linkVars = L` in my TS causes that `$this->redirect('other')` works as required without need for using `uriBuilder`, TYPO3 ver. 6.1.x, common extension built with the Extension Builder – biesior Aug 05 '13 at 17:39
  • The site I'm working on still runs 4.7, that may be the problem. One more reason to convince the customer to do an upgrade :-) – Michael Aug 05 '13 at 18:03