Usually a view in extbase is always called from a controller. but what if, an action in your controller is called as an eID and only parts of the template needs to be rendered? Partial is an option, but I have a code snippet, which uses the
1 |
TYPO3\\CMS\\Fluid\\View\\StandaloneView |
class.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
/** * get Standalone view * * @param string $templateFilename * @return \TYPO3\CMS\Fluid\View\StandaloneView */ protected function getStandAloneTemplate ($templateFilename) { /** @var \TYPO3\CMS\Fluid\View\StandaloneView $standAloneView */ $standAloneView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView'); // format of the template file $standAloneView->setFormat('html'); $extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); // get the TypoScript config for the template $templateRootPath = GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['view']['standaloneRootPath']); // set template path and filename $templatePathAndFilename = $templateRootPath . $templateFilename; $standAloneView->setTemplatePathAndFilename($templatePathAndFilename); return $standAloneView; } |
and don’t forget to define the standaloneRootPath
in your TypoScript:
1 |
plugin.tx_yourextension.view.standaloneRootPath = EXT:yourExtension/Resources/Private/Standalone/ |