Fluid without Extbase
Thinking about a flexible solution for an email template, I found a interesting suggestion in a presentation by Patrick Lobacher of typofaktum. On slide 39 he has posted some code to use Fluid without Extbase. Based on his code, I ended up using this code:
$renderer = t3lib_div::makeInstance('Tx_Fluid_View_TemplateView'); $renderer->setControllerContext(t3lib_div::makeInstance('Tx_Extbase_MVC_Controller_ControllerContext')); $template = t3lib_extMgm::extPath(strtolower($this->extensionName)) . 'Resources/Private/...'; $renderer->setTemplatePathAndFilename($template); $renderer->assign('helloworld', $helloworld); $rendered = $renderer->render();
If you get an error stating that the renderer expected an Extbase object but was boolean, you should check for a typo in your $template path.
Patrick also uses $_EXTKEY to get the extension path, but in my controller the variable is not available. In my case, “strtolower($this->extensionName)” fits the extension key perfectly so I chose to use it to get the correct path.
Since I did not want to send HTML mails and my Fluid Template, I use the rendered result to pass it to t3lib_htmlmail’s “addPlain($mailBody)” function to send my email.
For newer Extbase-Versions you have to use t3lib_div::makeInstance(‘Tx_Fluid_View_StandaloneView’);!