Open nhovratov opened 3 months ago
Step 1: Create a new Content Element:
config.yaml
name: vendor/artists-list
typeName: vendor_artists_artists
group: plugins
frontend.html
<f:cObject typoscriptObjectPath="{data.mainType}.{data.recordType}" table="{data.mainType}" data="{data}"/>
Step 2: Add TypoScript
setup.typoscript
tt_content.vendor_artists_artists = EXTBASEPLUGIN
tt_content.vendor_artists_artists {
extensionName = Artists
pluginName = Artists
}
Step 3: Register Controller Actions
ext_localconf.php
ExtensionUtility::registerControllerActions(
'Artists',
'Artists',
[
ArtistController::class => ['list']
],
[
ArtistController::class => []
]
);
TYPO3 has a helper method to quickly create plugins in ExtensionUtility::configurePlugin/registerPlugin
In the background, it will create a completely new Content Element, which just copies the "Header" element. If you need custom fields or FlexForm configuration, you need to manually override the element. But if you create the Content Element with Content Blocks and only register the controller actions for it via the utility, you have the full power of Content Blocks on your side. You can quickly create FlexForm config and manage labels, icons etc. in your component.
Note: registerControllerActions is an internal method, but it is unlikely to change in version 13. This way of adding plugins is experimental. The idea to separate Content Element registration and controller action registration is a good one in my opinion.
There are plans to further simplify the registration of extbase plugins with Content Blocks. I didn't go into the Content Blocks Core, because this would introduce a dependency to extbase, which we don't want: https://github.com/FriendsOfTYPO3/content-blocks/pull/95
This will probably be an addon to Content Blocks, as soon as we have an API to register custom Content Types.