试试这个函数来获取任何流畅的模板 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);