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でそれは働いています!

誰かがアイデアを持っていることを願っています。前もって感謝します!

4

1 に答える 1

1

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)は変更されません。

于 2012-01-04T21:31:14.353 に答える