typo3-contentblocks / contentblocks-reg-api
This API provides an easy and reliable way to register content blocks as standalone packages.
Installs: 4 193
Dependents: 0
Suggesters: 0
Security: 0
Stars: 19
Watchers: 11
Forks: 7
Open Issues: 24
Type:typo3-cms-extension
Requires
- php: ^7.2 || ^8.0
- ext-json: *
- typo3-contentblocks/composer-plugin: ^2.0
- typo3/cms-core: ^10.4 || ^11.5
- typo3/cms-filelist: ^10.4 || ^11.5
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0.0
- helhum/typo3-console: ^6.6 || ^7.0
- rector/rector: ^0.12.19
- roave/security-advisories: dev-master
- typo3-contentblocks/call-to-action-local: @dev
- typo3-contentblocks/counter-local: @dev
- typo3-contentblocks/example-local: @dev
- typo3-contentblocks/fluid-styled-content-example-local: @dev
- typo3-contentblocks/slider-local: @dev
- typo3/cms-about: ^10.4 || ^11.5
- typo3/cms-adminpanel: ^10.4 || ^11.5
- typo3/cms-backend: ^10.4 || ^11.5
- typo3/cms-belog: ^10.4 || ^11.5
- typo3/cms-beuser: ^10.4 || ^11.5
- typo3/cms-dashboard: ^10.4 || ^11.5
- typo3/cms-extbase: ^10.4 || ^11.5
- typo3/cms-extensionmanager: ^10.4 || ^11.5
- typo3/cms-felogin: ^10.4 || ^11.5
- typo3/cms-filemetadata: ^10.4 || ^11.5
- typo3/cms-fluid: ^10.4 || ^11.5
- typo3/cms-fluid-styled-content: ^10.4 || ^11.5
- typo3/cms-form: ^10.4 || ^11.5
- typo3/cms-frontend: ^10.4 || ^11.5
- typo3/cms-impexp: ^10.4 || ^11.5
- typo3/cms-indexed-search: ^10.4 || ^11.5
- typo3/cms-info: ^10.4 || ^11.5
- typo3/cms-install: ^10.4 || ^11.5
- typo3/cms-linkvalidator: ^10.4 || ^11.5
- typo3/cms-lowlevel: ^10.4 || ^11.5
- typo3/cms-opendocs: ^10.4 || ^11.5
- typo3/cms-recordlist: ^10.4 || ^11.5
- typo3/cms-recycler: ^10.4 || ^11.5
- typo3/cms-redirects: ^10.4 || ^11.5
- typo3/cms-reports: ^10.4 || ^11.5
- typo3/cms-rte-ckeditor: ^10.4 || ^11.5
- typo3/cms-scheduler: ^10.4 || ^11.5
- typo3/cms-seo: ^10.4 || ^11.5
- typo3/cms-setup: ^10.4 || ^11.5
- typo3/cms-sys-note: ^10.4 || ^11.5
- typo3/cms-t3editor: ^10.4 || ^11.5
- typo3/cms-tstemplate: ^10.4 || ^11.5
- typo3/cms-viewpage: ^10.4 || ^11.5
- typo3/cms-workspaces: ^10.4 || ^11.5
- typo3/coding-standards: ^0.4.0
- typo3/tailor: ^1.3
- typo3/testing-framework: ^6.4
README
Registration API for Content Blocks
⚠️ Attention: This is the API for TYPO3 v11 ⚠️
For TYPO3 v12, you can find the github repository here or on TER here.
Introduction
This API provides an easy and reliable way to register content blocks (composer packages). Follow this README for a quick getting started overview. Find the full Documentation inside this repository.
Status
beta
- the main concepts are laid out, the data storage method refactored and tested. We welcome your feedback.
You can reach us in the TYPO3 Slack #cig-structuredcontent
❤️.
Installation
For developing on this API
This will set up a TYPO3 v10 with ddev and install the API extension.
Requirements
- ddev
- Clone this repository
- Run
ddev launch /typo3
The TYPO3 backend user is "admin", password "adminadmin".
It includes example Content Blocks in a local composer repository that are installed by default.
For using Content Blocks
Requirements
- TYPO3 v10+
- In TYPO3 v10, backend previews require the Fluid based Page module to be enabled.
The API required to use content blocks consists of 2 composer packages: an API extension and a composer plugin.
Installation steps
composer req typo3-contentblocks/contentblocks-reg-api
- Activate the extension
contentblocks_reg_api
- Add new database fields: (Backend)
Maintenance
›Analyze Database Structure
Getting/Creating new content blocks
Via composer
This is an example repo with a content block
composer req typo3-contentblocks/call-to-action:dev-master
For using custom content blocks in your project we recommend a local "path" composer repository.
Wizard
There is a wizard module that kickstarts Content Blocks for you.
Create them locally
You can also add a Content Block directory manually to typo3conf/contentBlocks
.
Usage
Processes that happen during content block registration
Detecting a content block
The detection of content blocks depends on the composer package type.
The custom composer installer then retrieves all packages, which are of type typo3-contentblock
.
Validation
Following aspects are mandatory for a content block to be validated successfully:
- An icon for the content block named "ContentBlockIcon" hast to be present in the package root and of type SVG/PNG/GIF
- The file
EditorInterface.yaml
has to be present in the package root and valid - The backend language file
Default.xml
orEditorInterface.xlf
has to be present in thesrc/Language
folder of the package - The file
EditorPreview.html
has to be present in thesrc
folder of the package
Location
Content blocks are stored in or symlinked to typo3conf/contentBlocks/
.
Virtual generation of TCA
TCA is virtually generated from the class implementing a content block field type.
Generation of FlexForm
Based on the fields defined in the EditorInterface.yaml
a FlexForm for the editing interface of the content block
is generated and stored in tt_content.content_block
.
Registration of the content block
- Register icon
- Add TCA entry in CTypes list including the icon
- Add the content block to the NewContentElementWizard
- Add TypoScript to render the content plugin
- Add PageTS for the content block
Extension configuration
For some reason it might be necessary to inherit content blocks from your own definition. E. g. if you want to inherit content blocks from lib.contentElement. In that case you can extend the default TypoScript as you need. This is the default Code:
lib.contentBlock = FLUIDTEMPLATE lib.contentBlock { layoutRootPaths { -5 = EXT:contentblocks_reg_api/Resources/Private/Layouts/ } partialRootPaths { 0 = EXT:contentblocks_reg_api/Resources/Private/Partials/ } dataProcessing { 10 = Typo3Contentblocks\ContentblocksRegApi\DataProcessing\CbProcessor 20 = Typo3Contentblocks\ContentblocksRegApi\DataProcessing\FlexFormProcessor } }
Attention: If you change the code, you are responsible for that the code is working. Beware of data processing. Your content block won't work without that.
You can inject your code via the extension settings in the install tool. There you can set the default TypoScript to your specific file like EXT:sitepackage/Configuration/TypoScript/contentBlock.typoscript
.
The second thing in the extension configuration is to enable the frame pallet in the appearance section. This might be a helpful feature if you are using fluid_styled_content or bootstrap_package.