The Backend Template View without Extbase


If you want to do extensive data modeling you may want to use Extbase templating. If you build a simple backend module it makes sense to work without Extbase.

Basic controller

When creating a controller without Extbase an instance of ModuleTemplate is required to return the rendered template:

class ListController
    protected ModuleTemplate $moduleTemplate;

     * Constructor Method
     * @var ModuleTemplate $moduleTemplate
    public function __construct(ModuleTemplate $moduleTemplate = null)
        $this->moduleTemplate = $moduleTemplate ?? GeneralUtility::makeInstance(ModuleTemplate::class);

   // ...

Main entry point

handleRequest() method is the main entry point which triggers only the allowed actions. This makes it possible to include e.g. Javascript for all actions in the controller.

public function handleRequest(ServerRequestInterface $request): ResponseInterface
   $action = (string)($request->getQueryParams()['action'] ?? $request->getParsedBody()['action'] ?? 'index');

    * Define allowed actions
   if (!in_array($action, ['index'], true)) {
      return new HtmlResponse('Action not allowed', 400);

    * Configure template paths for your backend module
   $this->view = GeneralUtility::makeInstance(StandaloneView::class);

    * Call the passed in action
   $result = $this->{$action . 'Action'}($request);

   if ($result instanceof ResponseInterface) {
      return $result;

    * Render template and return html content
   return new HtmlResponse($this->moduleTemplate->renderContent());


Now create an indexAction() and assign variables to your view as you would normally do

public function indexAction()

          'some-variable' => 'some-value',

The DocHeader

To add a DocHeader button use $this->moduleTeamplate->getDocHeaderComponent()->getButtonBar() and makeLinkButton() to create the button. Finally use addButton() to add it.

private function setDocHeader(string $active) {
   $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
   $list = $buttonBar->makeLinkButton()
      ->setTitle('A Title')
      ->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-extension-import', Icon::SIZE_SMALL));
   $buttonBar->addButton($list, ButtonBar::BUTTON_POSITION_LEFT, 1);

Template example

Default layout


   <f:render section="content" />

Index template

<f:layout name="Default" />

<f:section name="content">