0
votes

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!

1

1 Answers

1
votes

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.