0
votes

I try to generate a csv-file in my TYPO3 Extension. I get following error:

1225709595: The Fluid template files "" could not be loaded. (More information)

TYPO3Fluid\Fluid\View\Exception\InvalidTemplateResourceException thrown in file /usr/local/www/apache24/xx/xx/vendor/typo3fluid/fluid/src/View/TemplatePaths.php in line 719.

25 TYPO3Fluid\Fluid\View\TemplatePaths::resolveFileInPaths(array, "Default", "csv")

My Controller looks like:

$icalView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
                $extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);

$icalView->setFormat('csv');

                $icalView->setTemplatePathAndFilename('typo3conf/ext/xxx/Resources/Private/Templates/Bestellung/Listbestellungen.txt'); 
                
                $icalView->assign('xx', $xx);
                
                $icalContent = $icalView->render();

I do have Subfolter "Layout" in ... Bestellung/ and I do have file Default.csv

Same code working in extension in TYPO3 7.6.x - what has changed in 8.7?

Thanks for help! Martin

2

2 Answers

1
votes

Here an snippet how I do it in 8.7 to send an eMail:

As I know you have to set the paths for Template, Layout and Partials also, before you select the template to use

/**
 * configurationManager
 *
 * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManager
 * @inject
 */
protected $configurationManager;

public function sendEmail($template,...)
{
    /**
     * Generate Email Body
     */

    $extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);

    /** @var StandaloneView $emailView */
    $emailView = $this->objectManager->get(StandaloneView::class);
    $emailView->getRequest()->setControllerExtensionName($controllerExtensionName);
    $emailView->getRequest()->setPluginName($pluginName);
    $emailView->getRequest()->setControllerName($controllerName);

    $emailView->setTemplateRootPaths($extbaseFrameworkConfiguration['view']['templateRootPaths']);
    $emailView->setLayoutRootPaths($extbaseFrameworkConfiguration['view']['layoutRootPaths']);
    $emailView->setPartialRootPaths($extbaseFrameworkConfiguration['view']['partialRootPaths']);

    $emailView->setTemplate('Email/' . ucfirst($template));
    $emailView->assignMultiple($variables);

    $emailBody = $emailView->render();
}
0
votes

I solved this by changing the code a little bit and now it is working:

$storage = $this->resourceFactory->getDefaultStorage();
                if ($storage === NULL) {
                    throw new \RuntimeException('Could not get the default storage', 1475590001);
                }




                /** @var \TYPO3\CMS\Fluid\View\StandaloneView $icalView */
                $icalView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
                $icalView->setFormat('csv');

                $templateRootPath[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:xxx/Resources/Private/Templates/');
                $layoutRootPaths[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:xxx/Resources/Private/Layouts/');
                $partialRootPaths[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:xxx/Resources/Private/Partials/');

                $icalView->setLayoutRootPaths($layoutRootPaths);
                $icalView->setPartialRootPaths($partialRootPaths);
                $icalView->setTemplatePathAndFilename('typo3conf/ext/xxx/Resources/Private/Templates/Bestellung/Listbestellungen.txt');

                $icalView->assign('xxx', $xxx);

                $icalContent = $icalView->render();

                $tempFolder = $storage->getFolder('bestellungencsv');
                $tempFile = $storage->createFile('bestellungen_'.$xxx->getUid().'.csv', $tempFolder);
                $tempFile->setContents($icalContent);