Вот простая функция, которую я написал для рендеринга моих шаблонов.
/**
* Renders the 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 is a test!'));
И шаблон жидкости в typo3conf/внутр/MyTemplate/Ресурсы/Private/Templates/mail.html может выглядеть так:
Hello
{test}
С выходом
Hello
This is a test!
Вам нужны макеты и частичные?
/**
* Returns the 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();
}
TIP: вместо того, чтобы использовать 'eID' - использовать действие Extbase с Bootstrap в TypoScript с выделенной типа страницы. – biesior
Но если мне не нужны TSFE и другие тяжелые вещи, то eID является предпочтительным решением. А как насчет рендеринга двух разных «просмотров» в одном запросе? – Ludwig
вы можете использовать StandaloneView или '$ this-> forward ('other')' для рендеринга 'otherAction()' – biesior