Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guide: Plugins / UserFunc and Extbase #231

Open
nhovratov opened this issue Aug 26, 2024 · 2 comments
Open

Guide: Plugins / UserFunc and Extbase #231

nhovratov opened this issue Aug 26, 2024 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@nhovratov
Copy link
Contributor

nhovratov commented Aug 26, 2024

  • How to register a Plugin with Content Blocks
  • How to register Controller Actions
  • How to render the extbase view / userFunc
@nhovratov nhovratov added the documentation Improvements or additions to documentation label Aug 26, 2024
@nhovratov
Copy link
Contributor Author

nhovratov commented Nov 17, 2024

Create Extbase Plugins with Content Blocks

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 => []
    ]
);

Why not just use configurePlugin / registerPlugin?

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.

@nhovratov
Copy link
Contributor Author

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: #95

This will probably be an addon to Content Blocks, as soon as we have an API to register custom Content Types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant