typo3-extension-workshop/Documentation/source/UnderstandTypo3Plugins.rst
Daniel Siepmann 58030d7b69
TASK: Remove example plugin
* In order to not waste time.
* In order to not irritate participants with two plugins.
2019-03-01 10:32:32 +01:00

2 KiB

Understand TYPO3 Plugins

What happened until now?

We created an extension and a very basic plugin.

The plugin is created with two API calls and a Controller class with a single action method.

What exactly are the API calls doing? And what does the PHP code in our Controller do so far? Let's understand TYPO3!

TYPO3 Backend

The TYPO3 Backend needs to provide a new Plugin to the editor, this is done within Configuration/TCA/Overrides/tt_content.php.

The API configures the TCA (=Table Configuration Array) for tt_content. And adds the new plugin as list_type.

We can go further on the content element during the Topic configuration, especially configuration-content-wizard.

TYPO3 Frontend rendering

Also we need to configure the handling of our plugin during the rendering of TYPO3 frontend. This is done within ext_localconf.php.

The API configures TypoScript tt_content.list.20.<pluginSignature> to define rendering of the new registered list_type.

Extbase bootstrap will be started with extension and plugin name. Also the configuration of callable controller actions and caching is stored in $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'].

The controller

TypoScript will call Extbase, which will figure out to call the indexAction method of our AddressController, thanks to our frontend rendering configuration.

The default action is always the first action of the first controller in the configuration. Multiple actions will be shown later.

The Controller should extend the ActionController to work as expected out of the box. Also all "actions" must have the suffix Action and need to be public.

As soon as an action returns a string, this will be the output. If nothing is returned, which is null Extbase will try to find and render a template matching our current controller and action. This is done at \TYPO3\CMS\Extbase\Mvc\Controller\ActionController::callActionMethod.