简体   繁体   中英

TYPO3 StandaloneView not finding Templates

I am using the StandaloneView to output some data.

The problem I encountered is that the given TemplateRootPath is just ignored.
TYPO3 throws an exception saying that it looked for the template in /typo3/public/typo3conf/ext//Resources/Private/Templates/ but the given TemplateRootPath is one folder further down in /printView/.

Maybe there is something that went over my head but I am looking for a fix for about one and a half hours now.

$standaloneView = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Fluid\View\StandaloneView::class);
$standaloneView->setLayoutRootPaths([
    \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:<my-extension>/Resources/Private/Layouts/printView/'),
]);
$standaloneView->setPartialRootPaths([
    \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:<my-extension>/Resources/Private/Partials'),
]);
$standaloneView->setTemplateRootPaths([
    \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:<my-extension>/Resources/Private/Templates/printView/'),
]);
$standaloneView->setFormat('html');
$standaloneView->setTemplate('printView/printView');
$standaloneView->assignMultiple([
    //variable assignment
]);

echo $standaloneView->render(); 

<my-extension> is there on purpose

set...RootPaths(...) expects an array as parameter.

Maybe you need to change the filename of the template to UpperCamelCase.
That might not be needed for the parameter you use for selection, but the generated filename will have it. ( PrintView.html instead of printView.html )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM