0
votes

I want my calendar extension to return XML and iCal output while avoiding the need of any additional TypoScript (additional page or typeNum). For this purpose I created a dedicated export controller. The correct XML extension template is being loaded but wrapped in the regular HTML page template.

Here’s what I tried in ExportController->listAction(). The following line does what I hoped it would as there is no HTML <head> section in the output:

$GLOBALS['TSFE']->config['config']['disableAllHeaderCode'] = 1;

With the following line instead the page is still being parsed completely although I can see the changes in the f:debug output of $GLOBALS['TSFE']->tmpl->setup:

$GLOBALS['TSFE']->tmpl->setup['page.']['10.']['file'] = 'path/to/empty/templatefile.xml';

I even went further and tried to override all template settings from my TypoScript ($GLOBALS['TSFE']->tmpl->setup['page.']['10.']['file.']['stdWrap.']['cObject.']['default.']) – with the same result.

While, when setting $GLOBALS['TSFE']->tmpl->setup = null;, some of the page content is gone: all the output after the extension’s XML template and above it all the content elements – but that part of the template is still there.

Additionally – and unsuccessfully – I tried this:

$this->objectManager->get(\TYPO3\CMS\Core\Page\PageRenderer::class)->setTemplateFile('path/to/empty/templatefile.xml');

Is there any non-TypoScript way to achieve what I want?

1

1 Answers

1
votes

The action template file gets resolved before your controller action gets called. The only way that I know of, is to override methods on the controller such as setViewConfiguration and programatically add an additional template root path - but this is not necessarily compatible with your use case. It requires that the template object not specify a template path and filename, it must only specify a template name and a (set of) template root paths.

Your use case looks like the file path and filename get set in TS, in which case, no, you cannot override this outside of TS.

Sometimes, accepting you need to use TS for some things is just the easier way. It's how TYPO3 was designed, after all.