Dynamic Layout Handle

A layout handle is a XML tag which allow to determine which blocks are loaded depending on the current path.

For example, contentmanager_index_content is the handle which will be used on a content view page.

The default layout for a content view is:

page xmlns:xsi=<span class="string">"http://www.w3.org/2001/XMLSchema-instance"</span> layout=<span class="string">"1column"</span> xsi:noNamespaceSchemaLocation=<span class="string">"urn:magento:framework:View/Layout/etc/page_configuration.xsd"</span>>
``` <br></br>```
   head><br></br>
``` ```
       <br></br>
``` ```
  <span class="keyword"><br></br></span>
``` ```
   body><br></br>
``` ```
       referenceContainer name=<span class="string">"content"</span>><br></br>
``` ```
           referenceBlock name=<span class="string">"page.main.title"</span> remove=<span class="string">"true"</span>/><br></br>
``` ```
           block class=<span class="string">"Blackbird\ContentManager\Block\View"</span> name=<span class="string">"contentmanager_view"</span> /><br></br>
``` ```
       <span class="keyword"><br></br></span>
``` ```
   <span class="keyword"></span>

``The dynamic layout handle will permits to add specific block or layout for a defined content type.

Let's say we want to add a cms block in the left column of our blog content type. We will use then CONTENT_TYPE_VIEW_blog.xml as layout file

referenceContainer name=<span class="string">"left"</span>><br></br>
``` ```
    block class=""<span class="string">"Magento\Cms\Block\Block"</span> name=<span class="string">"my-custom-block"</span>><br></br>
``` ```
        action method=<span class="string">"setBlockId"</span>>my-custom-blockargument>action><br></br>
``` ```
    block><br></br>``

Let's say we want to add a cms block in the left column of our archive content list (only created from the backend). We will use then CONTENT_LIST_VIEW_archive.xml as layout file

referenceContainer name="left"> <br></br> block class="Magento\Cms\Block\Block" name="my-custom-block"> <br></br> action method"setBlockId">my-custom-blockargument>action> <br></br> block>

/`referenceContainer>```

Chargement en cours...