【问题标题】:How can the current language be added to an extbase redirect?如何将当前语言添加到 extbase 重定向?
【发布时间】:2013-08-06 11:25:24
【问题描述】:

在我的 extbase 控制器操作中,我想在上传文件后重定向到另一个控制器/操作,所以我调用

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

问题是,当前语言参数在重定向期间丢失。方法签名允许$arguments 的数组在第四个位置,但如果我把L 放在那里

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

重定向用扩展参数的东西来包装它

&tx_myext_controller[L]=0

所以我的问题是:如何将当前语言添加到 extbase 重定向?

【问题讨论】:

    标签: typo3 extbase


    【解决方案1】:

    当我想要转义 $this->redirect 方法的命名空间时,我经常使用的快速提示。我正在使用$this->redirectToUri($uri),其中$uri 是用uriBuilder 准备的(这可能比普通重定向更灵活)。

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

    【讨论】:

    • 工作就像一个魅力,但如果我在打字稿中将L 添加到我的config.linkVars 中,这不是一个错误。在我看来,语言(或 linkVars 中定义的任何语言)也应该添加到那里。
    • 嗯,很奇怪,我刚刚检查过:config.linkVars = L 在我的 TS 中导致 $this->redirect('other') 按要求工作,而无需使用 uriBuilder,TYPO3 版本。 6.1.x,使用 Extension Builder 构建的通用扩展
    • 我正在处理的网站仍然运行 4.7,这可能是问题所在。说服客户进行升级的另一个理由:-)
    猜你喜欢
    • 2019-11-09
    • 2023-04-10
    • 1970-01-01
    • 2012-09-09
    • 1970-01-01
    • 1970-01-01
    • 2015-11-30
    • 2016-04-15
    • 2019-10-16
    相关资源
    最近更新 更多