Render a Page¶
Page is a special content type that contains a Page Field.
A Page Field is a layout composed of zones. Each zone can contain multiple blocks.
Render a layout¶
Configure layout¶
The default, built-in Page layout has only one zone.
You can create other layouts in configuration, under the ibexa_fieldtype_page.layouts
key.
To create a new layout called "Right sidebar", use the following configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Add layout template¶
A layout template renders all the zones of the layout.
Each zone must have a data-ibexa-zone-id
attribute with the number of the zone.
The best way to display blocks in the zone is to iterate over a blocks array and render the blocks in a loop.
Each block must have the landing-page__block block_{{ block.type }}
classes and the data-ez-block-id="{{ block.id }}
attribute.
To render the "Right sidebar" layout, add the following template to templates/themes/my_theme/layouts/sidebar.html.twig
:
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 32 |
|
Render a block¶
Every built-in Page block has a default template, which you can override. Every Page block can also have multiple other templates. The editor chooses a template when creating a block in the Page Builder.
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 ./bin/console c:c
.
In dev mode, the Symfony cache will be rebuilt automatically.
Block configuration¶
You can add new block templates by using configuration, for example, for the Content List block:
1 2 3 4 5 6 7 |
|
Tip
Use the same configuration to provide a template for custom blocks you create.
Block template¶
Create the block template file in the provided path, for example, templates/themes/my_theme/blocks/contentlist.html.twig
:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Override default block templates¶
To override the default block template, create a new template.
Place it in a path that mirrors the original default template from the bundle folder.
For example:
templates/bundles/IbexaFieldTypePageBundle/blocks/contentlist.html.twig
.
Tip
To use a different file structure when overriding default templates, add an import statement to the template.
For example, in templates/bundles/IbexaFieldTypePageBundle/blocks/contentlist.html.twig
:
1 |
|
Then, place the actual template in the imported file templates/blocks/contentlist/new_default.html.twig
.