Within the Ibexa DXP Page Builder, you define the layout of your pages by declaring content zones. Blocks are then dragged and dropped into these zones to build the page progressively, block by block.
Here's an example of a zone configuration within an Ibexa YAML file:
dlayout_three_rows_two_columns:
identifier: 'layout_three_rows_two_columns'
name: 'Three rows, two columns'
description: 'Three rows, two columns'
thumbnail: '/bundles/ibexadashboard/img/layouts/three_rows_two_columns.svg'
template: '@ibexadesign/dashboard/builder/layouts/three_rows_two_columns.html.twig'
zones:
top:
name: 'top'
middle_left:
name: 'middle-left'
middle_right:
name: 'middle-right'
bottom:
name: 'bottom'The “top” zone is named “top”, but this name doesn't appear anywhere in the Page Builder's page editing interface; it is identified as Drop zone 1:
The same principle applies in the Structure view (which is very useful for moving blocks from one zone to another): zones are identified as Drop zone 1, 2, 3, and so on:
What's the point of assigning a specific name in the configuration if that name isn't used anywhere?
Zone names are displayed in JavaScript by the following scripts:
const hasFieldset = zone.querySelector('fieldset') !== null;
if (!hasFieldset) {
const dropZoneLabel = Translator.trans(
/*@Desc("Drop zone %number%")*/ 'structure.drop.zone',
{
number: index + 1,
},
'ibexa_page_builder',
);
const fieldset = document.createElement('fieldset');
const legend = document.createElement('legend');It's hard to translate a text string when its label changes for each zone. In the page.builder.js script, we can see that if a <fieldset> element is already present in the zone's DOM, it isn't recreated.
Without getting into overly complex development or a kernel hack, we should be able to add this HTML block to our layout template to name our zones properly.
In our three_rows_two_columns.html.twig template, we therefore added the <fieldset> and <legend> elements with the zone name configured in our YAML file.
<div class="ibexa-db-zones">
<div class="ibexa-db-zones__row">
<div class="ibexa-db-zones__zone" data-ibexa-zone-id="{{ zones[0].id }}">
<fieldset class="m-page-builder__fieldset">
<legend class="m-page-builder__legend"
style="background-color: white; padding: 3px; border-radius: 5px; border: 1px dashed #4191ff;"
>
{{ zones[0].name }}
</legend>
</fieldset>
{% if zones[0].blocks %}
...
{% endif %}
</div>
</div>
<div class="ibexa-db-zones__row ibexa-db-zones__row--double">
<div class="ibexa-db-zones__zone" data-ibexa-zone-id="{{ zones[1].id }}">
<fieldset class="m-page-builder__fieldset">
<legend class="m-page-builder__legend"
style="background-color: white; padding: 3px; border-radius: 5px; border: 1px dashed #4191ff;"
>
{{ zones[1].name }}
</legend>
</fieldset>
{% if zones[1].blocks %}
...
{% endif %}
</div>
</div>
</div>
The preview zones are now self-explanatory and much easier to understand, especially in complex editorial management cases, such as the following example:
Without explicit zone names, the editorial team can't distinguish between a Cover zone, a zone with stackable blocks (which we'll discuss in a future article) and a free zone where blocks are displayed one below the other.
Any ideas on how to promote this feature, which should be native in the Structure view? I'm calling on the Ibexa team to bring us this small improvement with Ibexa 5.
Update of 16 October
We continued development and created a hack to get all the zones displayed with the desired name. Voilà!
If you would like to know more, please do not hesitate to contact us.
Cadeaux.com saw its Valentine's Day outperform Christmas with half as many servers. A look back ...
Since our last article, Ibexa Dataflow has gone from version 6.1.2 to 7.0.0: a richer ...
New dashboard, new design, new analyses and an ambitious roadmap: Security Audit moves to version ...
While AI assistants have revolutionised code production by significantly speeding up development, their widespread use ...
Fed up with having your job logs in the database? Even more fed up with ...
If you have been developing on Ibexa for a few years, you have probably got ...
Code Rhapsodie is taking over maintenance of Patrick Bussmann's oauth2-apple package. This fork ensures the ...
Taxonomy keyword suggestion is available in Ibexa DXP with the LTS update pack and the ...
Importing a very large SQL file can be problematic, sometimes causing your virtual machine (VM) ...