[TYPO3-mvc] If you want to render something with fluid directly

Steffen Ritter info at rs-websystems.de
Fri Feb 19 15:47:25 CET 2010


Nils Blattner schrieb:
> I had to generate creation mails and thought, why not make them with 
> fluid templates.
> It took me some time to find how to do it, but eventually I was able to 
> track the bugger down and crop away the unneded stuff.
> 
> $this->registerMail holds the absolute path to the template.
> 
>     
>     /**
>      * Returns a view which will be sent via mail.
>      *
>      * @return Tx_Fluid_View_TemplateView Template view.
>      */
>     protected function getCreateMailView() {
>          $view = 
> $this->objectManager->getObject('Tx_Fluid_View_TemplateView');
>         $controllerContext = $this->buildControllerContext();
>         $view->setControllerContext($controllerContext);
> 
>         // Template Path Override
>         $view->setTemplatePathAndFilename($this->registerMail);
>        
>         if (method_exists($view, 'injectSettings')) {
>             $view->injectSettings($this->settings);
>         }
>         $view->initializeView(); // In FLOW3, solved through Object 
> Lifecycle methods, we need to call it explicitely
>         $view->assign('settings', $this->settings); // same with 
> settings injection.
>         return $view;
>     }
Have a look to the extbase Wiki,
there i postes a function which initializes fluid as from controller and 
renders template.
With the short "version" you'll run into issues of viewhelpers asking 
for requests and sth. like this.

regards

Steffen


More information about the TYPO3-project-typo3v4mvc mailing list