Page blocks are configured in YAML files, under the
Keep in mind that Page block configuration is not SiteAccess-aware.
Ibexa DXP ships with a number of page blocks. For a list of all page blocks that are available out-of-the-box, see Page block reference.
For information on how to create and configure new layouts for the Page, see Page layouts.
Clear the persistence cache
Persistence cache must be cleared after any modifications have been made to the block config in Page Builder, such as adding, removing or altering the Page blocks, block attributes, validators or views configuration.
To clear the persistence cache run
./bin/console cache:pool:clear [cache-pool] command.
The default cache-pool is named
cache.tagaware.filesystem. The default cache-pool when running redis is named
cache.redis. If you have customized the persistence cache configuration, the name of your cache pool might be different.
In prod mode, you also need to clear the symfony cache by running
In dev mode, the Symfony cache will be rebuilt automatically.
Each configured block has an identifier and the following settings:
||Name of the block used in the Page Builder interface.|
||Category in the Page Builder elements menu that the block is shown in.|
||Thumbnail used in the Page Builder elements menu.|
||Available templates for the block.|
||(Optional) Toggles the block's visibility in the Page Builder elements menu. Remove the block from the layout before you publish another version of the page.|
||(Optional) Template for the block settings modal.|
||(Optional) List of block attributes.|
1 2 3 4 5 6 7 8 9 10 11 12 13 14
For a full example of block configuration, see Create custom Page block.
Overwriting existing blocks¶
You can overwrite the following properties in the existing blocks:
Page blocks can have multiple templates. This allows you to create different styles for each block and let the editor choose them when adding the block from the UI.
1 2 3 4 5 6 7 8 9 10 11 12
priority defines the order of block views on the block configuration screen.
The highest number shows first on the list.
Default views have a
priority of -255.
It is good practice to keep the value between -255 and 255.
Block modal template¶
The template for the configuration modal of built-in Page blocks is contained in
You can override it by using the
1 2 3 4 5 6 7
The template can extend the default
config.html.twig and modify its blocks.
design_tab_content correspond to the Basic and Design tabs in the modal.
The following example wraps all form fields for block attributes in an ordered list:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
To add functionalities to your block that go beyond the available attributes, you can use an event listener.
You can listen to events related to block definition and block rendering.
The following events are available:
BlockDefinitionEvents::getBlockDefinitionEventName- dispatched when block definition is created
BlockDefinitionEvents::getBlockAttributeDefinitionEventName- dispatched when block attribute definition is created
BlockRenderEvents::getBlockPreRenderEventName- dispatched before a block is rendered
BlockRenderEvents::getBlockPostRenderEventName- dispatched after a block is rendered
For example, to modify a block by adding a new parameter to it, you can create the following listener:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Before the block is rendered, the listener adds
my_parameter to it with value
You can use this parameter, for example, in block template:
1 2 3
Exposing content relations from blocks¶
Page blocks, for example Embed block or Collection block, can embed other Content items. Publishing a Page with such blocks creates Relations to those Content items.
When creating a custom block with embeds, you can ensure such Relations are created using the block Relation collection event.
The event is dispatched on content publication.
You can hook your event listener to the
To expose relations, pass an array containing Content IDs to the
If embedded Content changes, old Relations are removed automatically.
Providing Relations also invalidates HTTP cache for your block response in one of the related Content items changes.