TYPO3 Fluid:自 TYPO3 4.6 起使用自己的流体渲染器失败

发布于 2024-12-25 00:22:44 字数 1587 浏览 1 评论 0原文

我在扩展中使用了自己的流体渲染器:

/**
 * Makes and returns a fluid template object
 *
 * @return Tx_Fluid_View_TemplateView the fluid template object
 */
protected function makeFluidTemplateObject() {
    /** @var Tx_Fluid_View_TemplateView $fluidTemplate  */
    $fluidTemplate = t3lib_div::makeInstance('Tx_Fluid_View_TemplateView');

    // Set controller context
    $controllerContext = $this->buildControllerContext();
    $controllerContext->setRequest($this->request);
    $fluidTemplate->setControllerContext($controllerContext);

    return $fluidTemplate;
}

稍后我使用此 $fluidTemplate 来分配模板文件、变量并渲染它:

/**
 * Gets the mail message
 *
 * @param mixed $registration model to give to template
 * @param string $templatePath path of fluid template
 *
 * @return string The rendered fluid template (HTML or plain text)
 */
public function getMailMessage($registration, $templatePath) {
    $mailTemplate = t3lib_div::getFileAbsFileName($templatePath);
    if (!file_exists($mailTemplate)) {
        throw new Exception('Mail template (' . $mailTemplate . ') not found. ');
    }
    $this->fluidTemplate->setTemplatePathAndFilename($mailTemplate);

    // Assign variables
    $this->fluidTemplate->assign('registration', $registration);
    $this->fluidTemplate->assign('settings', $this->settings);

    return $this->fluidTemplate->render();
}

一切正常,除了 ->render()调用。从 TYPO3 4.6 开始,我收到错误 500,没有任何指定的异常。使用 TYPO3 4.5 LTS,它可以正常工作!

我希望有人有想法。提前致谢!

I used in an extension an own fluid renderer:

/**
 * Makes and returns a fluid template object
 *
 * @return Tx_Fluid_View_TemplateView the fluid template object
 */
protected function makeFluidTemplateObject() {
    /** @var Tx_Fluid_View_TemplateView $fluidTemplate  */
    $fluidTemplate = t3lib_div::makeInstance('Tx_Fluid_View_TemplateView');

    // Set controller context
    $controllerContext = $this->buildControllerContext();
    $controllerContext->setRequest($this->request);
    $fluidTemplate->setControllerContext($controllerContext);

    return $fluidTemplate;
}

I use this $fluidTemplate later to assign template-file, variables and render it:

/**
 * Gets the mail message
 *
 * @param mixed $registration model to give to template
 * @param string $templatePath path of fluid template
 *
 * @return string The rendered fluid template (HTML or plain text)
 */
public function getMailMessage($registration, $templatePath) {
    $mailTemplate = t3lib_div::getFileAbsFileName($templatePath);
    if (!file_exists($mailTemplate)) {
        throw new Exception('Mail template (' . $mailTemplate . ') not found. ');
    }
    $this->fluidTemplate->setTemplatePathAndFilename($mailTemplate);

    // Assign variables
    $this->fluidTemplate->assign('registration', $registration);
    $this->fluidTemplate->assign('settings', $this->settings);

    return $this->fluidTemplate->render();
}

Everything works, except the ->render() call. I get an error 500 without any specified exception, since TYPO3 4.6. With TYPO3 4.5 LTS it is working!

I hope someone has an idea. Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱&纷飞 2025-01-01 00:22:44

从 TYPO3 v4.6 开始,您不再需要构建整个控制器上下文。现在通过 Tx_Fluid_View_StandaloneView 处理 (Fluid 1.4.0)

初始化视图:

protected function makeFluidTemplateObject() {
    $this->fluidTemplate = t3lib_div::makeInstance('Tx_Fluid_View_StandaloneView');
    return $this->fluidTemplate;
}

函数 getMailMessage($registration, $templatePath) 保持不变。

Since TYPO3 v4.6 you don't need to build the whole controller context anymore. It's now handled via Tx_Fluid_View_StandaloneView (Fluid 1.4.0)

Initialize the view:

protected function makeFluidTemplateObject() {
    $this->fluidTemplate = t3lib_div::makeInstance('Tx_Fluid_View_StandaloneView');
    return $this->fluidTemplate;
}

The function getMailMessage($registration, $templatePath) remains unchanged.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文