This documentation is for a version that has reached its End Of Life. Such versions are no longer supported and don't receive security updates. Consider updating to a newer version.
A RichText block is a specific example of a custom block that you can use when you create a page.
To create a custom block, you must define the block's layout, provide templates, add a subscriber, and register the subscriber as a service.
Follow the procedure below to create a RichText page block.
First, provide the block configuration under the ibexa_page_fieldtype.blocksconfiguration key.
The following code defines a new block, its view and configuration templates.
It also sets the attribute type to richtext (line 15):
Make sure that you provide an icon for the block in the assets/images/blocks/ folder.
Then, create a subscriber that converts a string of data into XML code.
Create a src/Event/Subscriber/RichTextBlockSubscriber.php file.
In line 32, my_block is the same name of the block that you defined in line 3 above.
Line 32 also implements the PreRender method.
Lines 41-51 handle the conversion of content into an XML string:
Now you can create templates that are used for displaying and configuring your block.
Create the view template in templates/themes/<your-theme>/blocks/my_block/richtext.html.twig.
Line 2 is responsible for rendering the content from XML to HTML5:
You have successfully created a custom RichText block.
You can now add your block in the Site tab.
For more information about customizing additional options of the block or creating custom blocks with other attribute types, see Create custom Page block.