Doc officielle: Layout instructions, Common layout customization tasks.
- Ajouter une zone pleine largeur au-dessus du footer via un layout XML
- Ajouter un bloc statique dans la sidebar (left ou right column)
Ajouter une zone pleine largeur et contenant des blocs statiques au-dessus du footer via un layout XML
Testé fonctionnel Magento 2.3.
Dans le fichier app/design/frontend/<Vendor>/<theme>/Magento_Theme/layout/default.xml
:
1 2 3 4 5 |
<referenceContainer name="footer"> <container name="reinsurance" before="-"> <block class="Magento\Framework\View\Element\Template" name="theme.reinsurance" as="theme.reinsurance" template="Magento_Theme::html/theme_reinsurance.phtml"/> </container> </referenceContainer> |
Dans le fichier app/design/frontend/<Vendor>/<theme>/Magento_Theme/templates/html/theme_reinsurance.phtml
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<div id="reinsurance" class="reinsurance"> <div class="frame"> <div class="line"> <div class="reinsuranceItem col-des-4 col-tb-4 col-mb-12 col-mb-auto mg-bottom"> <?= $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('reinsurance_besoindAide')->toHtml(); ?> </div> <div class="reinsuranceItem col-des-4 col-tb-4 col-mb-12 col-mb-auto"> <?= $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('reinsurance_vosGaranties')->toHtml(); ?> </div> <div class="reinsuranceItem col-des-4 col-tb-4 col-mb-12 col-mb-auto"> <?= $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('reinsurance_espaceAbonnes')->toHtml(); ?> </div> <?php ?> </div> </div> </div> |
Depuis l’interface d’admin: Contenu > [Eléments] Blocs. Il faut avoir créé 3 blocs dont les identifiants sont:
- reinsurance_besoindAide
- reinsurance_vosGaranties
- reinsurance_espaceAbonnes
Ajouter un bloc statique dans la sidebar (left ou right column)
Dans mon exemple, je veux ajouter le bloc statique avec l’ID 64
dans le container sidebar.additional
de mes pages.
Je récupère le nom du referenceContainer
dans le fichier vendor/magento/module-theme/view/frontend/page_layout/2columns-left.xml
.
Dans le fichier app/design/frontend/MyVendor/mytheme/Magento_Theme/layout/default.xml
:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="sidebar.additional"> <block class="Magento\Cms\Block\Block" name="block_identifier"> <arguments> <argument name="block_id" xsi:type="string">64</argument> </arguments> </block> </referenceContainer> </body> </page> |