試試這個功能讓任何液體HTML模板。
public function getTemplateHtml($controllerName, $templateName, array $variables = array()) {
/** @var \TYPO3\CMS\Fluid\View\StandaloneView $tempView */
$tempView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
$extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$templateRootPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['view']['templateRootPath']);
$templatePathAndFilename = $templateRootPath . $controllerName . '/' . $templateName . '.html';
$tempView->setTemplatePathAndFilename($templatePathAndFilename);
$tempView->assignMultiple($variables);
$tempHtml = $tempView->render();
return $tempHtml;
}
就象在你例如,可以在answerAction
像調用此:
$this->getTemplateHtml($controllerName, 'question', $optMarkers);
$ this-> view-> render(「question」);也是我找到的一個解決方案。但你的工作也很棒。 –
是的,它也可以工作,但是如果你在同一個控制器中。 – UsmanZ