#108464ModuleTemplate: no way to change the "format"
Description
Following the current docs on BE modules I’ve created a BE controller (without extbase) that uses ModuleTemplate to render its content. See https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/HowTo/BackendModule/CreateModule.html
$moduleTemplate = $this->moduleTemplateFactory->create($this->request);
$moduleTemplate->setTitle('My thing');
return $moduleTemplate->renderResponse('Backend/List');
Unfortunately there’s no (documented) way of changing the format.
Any reason why ModuleTemplate shouldn’t have a getView() method? Then it’d be easy as this:
$moduleTemplate->getView()->getTemplatePaths()->setFormat('csv');
or add a 2nd parameter to the renderResponse() method?
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
History 1
-
Benni Mack commented and changed status
NewClosed <span data-processor="relativetime" data-value="2026-10-20T15:26:42+00:00" > 10/20/26, 15:26 </span>
ModuleTemplate always renders a full backend HTML document (doc header, body tag, JS modules), so a format switch there would still wrap CSV in HTML — that’s why there’s no getView() / format argument.
For non-HTML output, skip ModuleTemplate and use the generic view factory directly: inject TYPO3\CMS\Core\View\ViewFactoryInterface, create the view with new ViewFactoryData(templateRootPaths: […], request: $request, format: ‘csv’), and return your own response with a text/csv content type.