How to render a Fuid view template without Extbase? I. e an email template by eID -


i want send email typo3 eid script using fluid template file render mail body. not find simple way how initialize fuid view outside of normal mvc extbase context. sources found seemed outdated , complex.

so needed render fluid template?

here simple function wrote render templates.

/**  * renders fluid email template  * @param string $template  * @param array $assign  * @return string  */ public function renderfluidtemplate($template, array $assign = array()) {     $templatepath = \typo3\cms\core\utility\generalutility::getfileabsfilename('ext:myextension/resources/private/templates/' . $template);      $view = \typo3\cms\core\utility\generalutility::makeinstance('typo3\\cms\\fluid\\view\\standaloneview');     $view->settemplatepathandfilename($templatepath);     $view->assignmultiple($assign);      return $view->render(); }  echo renderfluidtemplate('mail.html', array('test' => 'this test!')); 

and fluid template in typo3conf/ext/mytemplate/resources/private/templates/mail.html that:

hello {test} 

with output

hello test! 

you need layouts , partials?

/**  * returns rendered fluid email template  * @param string $template  * @param array $assign  * @param string $ressourcepath  * @return string  */ public function renderfluidtemplate($template, array $assign = array(), $ressourcepath = null) {     $ressourcepath = \typo3\cms\core\utility\generalutility::getfileabsfilename($ressourcepath === null ? 'ext:myextension/resources/private/' : $ressourcepath);      /* @var $view \typo3\cms\fluid\view\standaloneview */     $view = \typo3\cms\core\utility\generalutility::makeinstance('typo3\\cms\\fluid\\view\\standaloneview');     $view->setlayoutrootpath($ressourcepath . 'layouts/');     $view->setpartialrootpath($ressourcepath . 'partials/');     $view->settemplatepathandfilename($ressourcepath . 'templates/' . $template);     $view->assignmultiple($assign);      return $view->render(); } 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -