Attention
TYPO3 v11 has reached end-of-life as of October 31th 2024 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here: TYPO3 ELTS.
Backend Template View (Extbase)
Tip
If you don't want to do extensive data modelling templates can be written without Extbase.
Deprecated since version 11.5
The general view class \TYPO3\
has been deprecated with v11.5. Use the
\TYPO3\
instead to
retrieve a Module
. See
Deprecation: #95164 - ext:backend BackendTemplateView
for more information.
Modern backend modules can be written using the Extbase/Fluid combination.
The factory \TYPO3\
can be used
to retrieve the \TYPO3\
class which is - more or less - the old backend module template,
cleaned up and refreshed. This class performs a number of basic
operations for backend modules, like loading base JS libraries,
loading stylesheets, managing a flash message queue and - in general -
performing all kind of necessary setups.
To access these resources, inject the
\TYPO3\
into your backend module
controller:
// use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
// use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
class MyController extends ActionController
{
protected ModuleTemplateFactory $moduleTemplateFactory;
public function __construct(
ModuleTemplateFactory $moduleTemplateFactory
) {
$this->moduleTemplateFactory = $moduleTemplateFactory;
}
}
After that you can add titles, menus and buttons using Module
:
// use Psr\Http\Message\ResponseInterface
public function myAction(): ResponseInterface
{
$this->view->assign('someVar', 'someContent');
$moduleTemplate = $this->moduleTemplateFactory->create($this->request);
// Adding title, menus, buttons, etc. using $moduleTemplate ...
$moduleTemplate->setContent($this->view->render());
return $this->htmlResponse($moduleTemplate->renderContent());
}
Using this Module
class, the Fluid templates for
your module need only take care of the actual content of your module.
As such, the Layout may be as simple as (again from "beuser"):
<f:render section="Content" />
and the actual Template needs to render the title and the content only. For example, here is an extract of the "Index" action template of the "beuser" extension:
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
xmlns:be="http://typo3.org/ns/TYPO3/CMS/Backend/ViewHelpers"
data-namespace-typo3-fluid="true">
<f:layout name="Default" />
<f:section name="Content">
<h1><f:translate key="backendUserListing" /></h1>
...
</f:section>
</html>
The best resources for learning is to look at existing modules from TYPO3. With the information given here, you should be able to find your way around the code.