{"id":17152,"date":"2018-11-06T15:15:15","date_gmt":"2018-11-06T13:15:15","guid":{"rendered":"https:\/\/belvg.com\/blog\/?p=17152"},"modified":"2025-02-11T10:08:37","modified_gmt":"2025-02-11T08:08:37","slug":"layout-xml-directives-and-their-arguments-in-magento-2","status":"publish","type":"post","link":"https:\/\/belvg.com\/blog\/layout-xml-directives-and-their-arguments-in-magento-2.html","title":{"rendered":"Layout XML Directives and Their Arguments in Magento 2"},"content":{"rendered":"\n<p>The key feature of the Magento platform is its modularity. It consists of a number of small elements (modules), which are designed to work both individually and In connection with each other. When all parts&nbsp;are combined, the platform resembles a living organism that consists of a multitude of cells, each having its own function.<\/p>\n<p><!--more--><\/p>\n<p>To connect these components and to manage their interactions, Magento 2 uses XML layouts and XML page configurations. Each web page of the store has its own XML file, in which a special syntax describes the structure and identifies all the elements necessary for displaying on it.<\/p>\n<p>All the elements used in these files are divided into two types: containers and blocks. According to the standard, containers are mainly used in XML layouts, while in XML configurations blocks are used. It directly depends on the functional load of each.<\/p>\n<p>XML layout serves to position the containers on the entire page, as well as to set the type of view and the structure. Here is an example of an XML template:<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;page xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" layout=\"2columns-left\"\r\n&nbsp;&nbsp;&nbsp;&nbsp;xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd\"&gt;\r\n&nbsp;&nbsp;&lt;body&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;referenceContainer name=\"columns.top\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container name=\"category.view.container\" htmlTag=\"div\" htmlClass=\"category-view\" after=\"-\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Catalog\\Block\\Category\\View\" name=\"category.image\"\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;template=\"Magento_Catalog::category\/image.phtml\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Catalog\\Block\\Category\\View\" name=\"category.cms\"\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;template=\"Magento_Catalog::category\/cms.phtml\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/container&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/referenceContainer&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;referenceContainer name=\"content\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Catalog\\Block\\Category\\View\" name=\"category.products\"\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;template=\"Magento_Catalog::category\/products.phtml\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container name=\"category.product.list.additional\" as=\"additional\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Framework\\View\\Element\\Template\"\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name=\"category.product.type.details.renderers.default\" as=\"default\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/block&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/block&gt;\r\n&nbsp;&nbsp;&lt;\/block&gt;\r\n&lt;\/page&gt;<\/pre>\n<p>XML configuration distributes each block separately into containers and also assigns each of them its own configurations, which we will see in more detail below.<\/p>\n<p>Often, these two concepts are blurred and it will be all right to combine layout and configuration files into one document. That&rsquo;s what happens if you add the configuration parameters to the above-mentioned document.<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;page xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" layout=\"2columns-left\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd\"&gt;\r\n&nbsp;&nbsp;&lt;body&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;referenceContainer name=\"columns.top\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container name=\"category.view.container\" htmlTag=\"div\" htmlClass=\"category-view\" after=\"-\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Catalog\\Block\\Category\\View\" name=\"category.image\" template=\"Magento_Catalog::category\/image.phtml\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Catalog\\Block\\Category\\View\" name=\"category.description\" template=\"Magento_Catalog::category\/description.phtml\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Catalog\\Block\\Category\\View\" name=\"category.cms\" template=\"Magento_Catalog::category\/cms.phtml\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/container&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/referenceContainer&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;referenceContainer name=\"content\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Catalog\\Block\\Category\\View\" name=\"category.products\" template=\"Magento_Catalog::category\/products.phtml\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Catalog\\Block\\Product\\ListProduct\" name=\"category.products.list\" as=\"product_list\" template=\"Magento_Catalog::product\/list.phtml\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container name=\"category.product.list.additional\" as=\"additional\" \/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Framework\\View\\Element\\RendererList\" name=\"category.product.type.details.renderers\" as=\"details.renderers\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Framework\\View\\Element\\Template\" name=\"category.product.type.details.renderers.default\" as=\"default\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/block&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Catalog\\Block\\Product\\ProductList\\Item\\Container\" name=\"category.product.addto\" as=\"addto\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Catalog\\Block\\Product\\ProductList\\Item\\AddTo\\Compare\"\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name=\"category.product.addto.compare\" as=\"compare\"\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;template=\"Magento_Catalog::product\/list\/addto\/compare.phtml\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/block&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Catalog\\Block\\Product\\ProductList\\Toolbar\" name=\"product_list_toolbar\" template=\"Magento_Catalog::product\/list\/toolbar.phtml\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Theme\\Block\\Html\\Pager\" name=\"product_list_toolbar_pager\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/block&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;action method=\"setToolbarBlockName\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;argument name=\"name\" xsi:type=\"string\"&gt;product_list_toolbar&lt;\/argument&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/action&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/block&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/block&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Cookie\\Block\\RequireCookie\" name=\"require-cookie\" template=\"Magento_Cookie::require_cookie.phtml\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;arguments&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;argument name=\"triggers\" xsi:type=\"array\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item name=\"compareProductLink\" xsi:type=\"string\"&gt;.action.tocompare&lt;\/item&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/argument&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/arguments&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/block&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/referenceContainer&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;referenceBlock name=\"page.main.title\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;arguments&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;argument name=\"id\" xsi:type=\"string\"&gt;page-title-heading&lt;\/argument&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;argument name=\"add_base_attribute_aria\" xsi:type=\"string\"&gt;page-title-heading toolbar-amount&lt;\/argument&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/arguments&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Catalog\\Block\\Category\\Rss\\Link\" name=\"rss.link\" template=\"Magento_Catalog::category\/rss.phtml\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/referenceBlock&gt;\r\n&nbsp;&nbsp;&lt;\/body&gt;\r\n&lt;\/page&gt;<\/pre>\n<p>The default layout and configuration files can be found here: <em>module_name\/view\/frontend\/ layout<\/em>.<\/p>\n<h2><strong>More about containers and blocks<\/strong><\/h2>\n<p>Containers in layouts can contain blocks and are designed to effectively position them within the page. The main containers include DOM elements such as:<\/p>\n<ul>\n<li>head<\/li>\n<li>header<\/li>\n<li>main<\/li>\n<li>aside (left or right)<\/li>\n<\/ul>\n<p>These elements divide our page layout into containers for conveniently arranging the blocks we need inside them. By default, 5 types of page layouts are pre-installed in Magento 2:<\/p>\n<ul>\n<li>empty (a page without containers)<\/li>\n<li>1 column (one general container for the content)<\/li>\n<li>2 column with left bar (a container for content with a left sidebar)<\/li>\n<li>2 column with right bar (a container for content with a right sidebar)<\/li>\n<li>3 column (3 optional containers)<\/li>\n<\/ul>\n<p><a href=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/11\/image3-1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"lazy aligncenter size-full wp-image-17179\" src=\"https:\/\/belvg.com\/wp-content\/uploads\/2019\/06\/pixel.png\" data-src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/11\/image3-1.png\" alt=\"Layout XML Directives and Their Arguments in Magento 2\" width=\"399\" height=\"100\" title=\"Layout XML Directives and Their Arguments in Magento 2\"><\/a><\/p>\n<p>The highlighted elements in the picture are our containers, we can place any blocks that are necessary on our page in them. Placing the blocks inside is the main distinguishing feature of the &lt;container&gt; element, but it is worth noting that if necessary, the &lt;block&gt; element can also contain other elements and even containers, and thus it automatically becomes a container for its child element. Therefore we can assume that the &lt;container&gt; and &lt;block&gt; elements are absolutely identical to each other, but they still have significant differences in their implementation and methods of working. Further, we will consider the main methods, their similarities and distinctive features.<\/p>\n<p>You should know that no one forbids creating custom layouts. You can select the grid for a specific page either via the admin panel at <em>Content &#10140; &nbsp;Pages &#10140; Target_Page_Edit &#10140; Design &#10140; Layout<\/em>.<\/p>\n<p><a href=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/11\/image5-1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"lazy aligncenter size-full wp-image-17154\" src=\"https:\/\/belvg.com\/wp-content\/uploads\/2019\/06\/pixel.png\" data-src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/11\/image5-1.png\" alt=\"Layout XML Directives and Their Arguments in Magento 2\" width=\"798\" height=\"425\" title=\"Layout XML Directives and Their Arguments in Magento 2\"><\/a><\/p>\n<p>or by using an xml layout of the page. To do this, we use a dedicated layout attribute for the &lt;page&gt; container, in which we specify which grid option we want to use on the page.<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;page xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" layout=\"2columns-left\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd\"&gt;\r\n&nbsp;&nbsp;&lt;body&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;referenceBlock name=\"page.main.title\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;arguments&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;argument name=\"id\" xsi:type=\"string\"&gt;page-title-heading&lt;\/argument&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;argument name=\"add_base_attribute_aria\" xsi:type=\"string\"&gt;page-title-heading toolbar-amount&lt;\/argument&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/arguments&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Magento\\Catalog\\Block\\Category\\Rss\\Link\" name=\"rss.link\" template=\"Magento_Catalog::category\/rss.phtml\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/referenceBlock&gt;\r\n&nbsp;&nbsp;&lt;\/body&gt;\r\n&lt;\/page&gt;<\/pre>\n<p>You can see the use of the &lt;page&gt; and &lt;body&gt; xml tags to configure our page containers, their syntax is very similar to the &lt;html&gt; syntax. Similarly to the html markup, all tags must be closed. In our situation they can be closed either by the &lt;\/page&gt; or &lt;\/body&gt; closing tags or they can be self-closing, such as the &lt;block name = &rdquo;blockName&rdquo; \/&gt; tag.<\/p>\n<p>&nbsp;<\/p>\n<p>All elements can have special attributes to control their parameters. Like containers, for example, have the <em>layout = &rdquo;Layout_View_Grid&rdquo;<\/em> attribute, in which we specify its 1column value. As for containers and blocks, the lists of attributes and their values are approximately the same:<\/p>\n<p style=\"display:none\">You can see the use of the &lt;page&gt; and &lt;body&gt; xml tags to configure our page containers, their syntax is very similar to the &lt;html&gt; syntax. Similarly to the html markup, all tags must be closed. In our situation they can be closed either by the &lt;\/page&gt; or &lt;\/body&gt; closing tags or they can be self-closing, such as the &lt;block name = &rdquo;blockName&rdquo; \/&gt; tag.You can see the use of the &lt;page&gt; and &lt;body&gt; xml tags to configure our page containers, their syntax is very similar to the &lt;html&gt; syntax. Similarly to the html markup, all tags must be closed. In our situation they can be closed either by the &lt;\/page&gt; or &lt;\/body&gt; closing tags or they can be self-closing, such as the &lt;block name = &rdquo;blockName&rdquo; \/&gt; tag.<\/p>\n<p style=\"text-align: center;\"><strong>Common attributes for blocks and containers<\/strong><\/p>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>Attribute<\/strong><\/td>\n<td><strong>Value<\/strong><\/td>\n<td><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td>name<\/td>\n<td><strong>0-9, A-Z, a-z &#1080; (-)(_)(.)<\/strong>\n<p>*Should start with a letter<\/p>\n<p>name=&rdquo;current_name&rdquo;<\/p><\/td>\n<td>A unique name for addressing is recorded.<\/td>\n<\/tr>\n<tr>\n<td>before<\/td>\n<td><strong>(-)<\/strong> an element is displayed <strong>before all<\/strong> in the current block.\n<p><strong>(element&rsquo;s name)<\/strong> displaying the element before the element with the specified name.<\/p>\n<p><strong>()<\/strong> if the parameter is missing, the element is considered to be non-positioned and is displayed according to the current layout.<\/p>\n<p>before=&rdquo;-&rdquo;<\/p><\/td>\n<td>This attribute is used to position the elements inside the page layout or inside the container itself.<\/td>\n<\/tr>\n<tr>\n<td>after<\/td>\n<td><strong>(-)<\/strong> an element is displayed <strong>after all<\/strong> in the current block or container.\n<p><strong>(element&rsquo;s name)<\/strong> displaying the element after the element with the specified name.<\/p>\n<p><strong>()<\/strong> if the parameter is missing, the element is considered to be non-positioned and is displayed according to the current layout.<\/p>\n<p>after=&rdquo;target_elemement&rdquo;<\/p><\/td>\n<td>This attribute is used to position elements inside the page layout or inside the container itself. Has an advantage over before.<\/td>\n<\/tr>\n<tr>\n<td>as<\/td>\n<td><strong>0-9, A-Z, a-z &#1080; (-)(_)(.)<\/strong>\n<p>*Should start with a letter<\/p>\n<p>name=&rdquo;current_allias&rdquo;<\/p><\/td>\n<td>The specified name is used to identify the current element in the parent element.<\/td>\n<\/tr>\n<tr>\n<td>cacheable<\/td>\n<td><strong>true, false<\/strong>\n<p>cacheable=&rdquo;false&rdquo;<\/p><\/td>\n<td>Enables and disables caching of pages where the elements with this attribute are located. It&rsquo;s necessary when creating dynamic elements, widgets and pages.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><em>*All attributes except name are optional.<\/em><\/p>\n<p>Attribute values and their functional load are identical for both blocks and containers. However, containers have methods that are unique only to them:<\/p>\n<p style=\"text-align: center;\"><strong>Container attributes<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>Attribute<\/strong><\/td>\n<td><strong>Value<\/strong><\/td>\n<td><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td>output<\/td>\n<td><strong>0 \/ 1<\/strong> or <strong>true \/ false<\/strong>\n<p>output=&rdquo;1&rdquo;<\/p><\/td>\n<td>This attribute is specified in order to determine whether to render the parent container in which the element is located. By default it&rsquo;s false.<\/td>\n<\/tr>\n<tr>\n<td>HtmlTag<\/td>\n<td>Html 5 &#1090;&#1077;&#1075;&#1080; (aside, main, div &hellip;)\n<p>HtmlTag=&rdquo;div&rdquo;<\/p><\/td>\n<td>Everything inside the container will be displayed to the user inside the specified tag.<\/td>\n<\/tr>\n<tr>\n<td>htmlId<\/td>\n<td><strong>0-9, A-Z, a-z &#1080; (-)(_)(.)<\/strong>\n<p>*Valid only when the HtmlTag value is set.<\/p>\n<p>htmlId=&rdquo;current_id_name&rdquo;<\/p><\/td>\n<td>The html Id selector for the specified wrapper is installed.<\/td>\n<\/tr>\n<tr>\n<td>htmlClass<\/td>\n<td><strong>0-9, A-Z, a-z &#1080; (-)(_)(.)<\/strong>\n<p>*Valid only when HtmlTag value is set.<\/p>\n<p>htmlClass=&rdquo;current_class_name&rdquo;<\/p><\/td>\n<td>The html class selector for the specified wrapper is installed.<\/td>\n<\/tr>\n<tr>\n<td>label<\/td>\n<td>Any value<\/td>\n<td>An arbitrary container name is set to display in a browser.<\/td>\n<\/tr>\n<tr>\n<td>layout<\/td>\n<td>The value of the page layout template name.\n<p>layout=&rdquo;grid_name&rdquo;<\/p><\/td>\n<td>It&rsquo;s used to set the required grid pattern.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><em>*the attributes are optional<\/em><\/p>\n<p>Let&rsquo;s also consider the parameters for specifying the attributes that are unique to blocks:<\/p>\n<p style=\"text-align: center;\"><strong>Block attribute<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>Attribute<\/strong><\/td>\n<td><strong>Value<\/strong><\/td>\n<td><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td>class<\/td>\n<td>The path to the class and its name:\n<p><em>class=&rdquo;Vendor\\Folder_Name\\Block\\Class_Folder\\Class_Name&rdquo;<\/em><\/p><\/td>\n<td>This attribute specifies the path to the class that is responsible for processing the information for the current template block. It is used to point a new element to its handler or to overwrite the current program block handler with a custom one.<\/td>\n<\/tr>\n<tr>\n<td>template<\/td>\n<td>The path to the template and its name:\n<p>template=&rdquo;Vendor_Name::folder_template\/name_template.phtml&rdquo;<\/p><\/td>\n<td>This attribute specifies the path to the template that is responsible for rendering information for the current layout block. It is used to specify a new element for its template or to overwrite the default template with a custom one.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><em>*the values are optional<\/em><\/p>\n<h4><span style=\"color: #000000;\"><strong>Instructions<\/strong><\/span><\/h4>\n<p>The so-called instructions are an additional tool for working with XML file layouts and page configurations in Magento 2. These include the &lt;block&gt; and &lt;container&gt; tags themselves, as well as a number of auxiliary ones. These are the main ones:<\/p>\n<h4><span style=\"color: #000000;\"><strong>referenceBlock&nbsp;and referenceContainer<\/strong><\/span><\/h4>\n<p>An instruction that is applied respectively to a block or container in order to pass on the necessary parameters using the following attributes:<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>Attribute<\/strong><\/td>\n<td><strong>Value<\/strong><\/td>\n<td><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td>name<\/td>\n<td>The name of the target block or container<\/td>\n<td>Indicates the name of the block or container to which the instructions will be passed.<\/td>\n<\/tr>\n<tr>\n<td>remove<\/td>\n<td>true\/false<\/td>\n<td>Deletes or cancels the deletion of the current block or container. When a container is deleted, all the child elements are deleted as well.<\/td>\n<\/tr>\n<tr>\n<td>display<\/td>\n<td>true\/false<\/td>\n<td>Turns off or cancels the shutdown of the rendering on the page of the current container or block. When an item is disabled, the further possibility of manipulating it and its child elements is preserved.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4><strong><span style=\"color: #000000;\">Nested attributes<\/span><\/strong><\/h4>\n<p>Magento 2 has several attributes in stock that can be inserted inside, the syntax is familiar to us from the declaration of containers and blocks and looks something like this:<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;layout xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_layout.xsd\"&gt;\r\n&nbsp;&nbsp;&lt;move element=\"category.cms\" destination=\"page.wrapper\" after=\"category.view.container\"\/&gt;\r\n&lt;\/layout&gt;<\/pre>\n<p>An example of move instructions for rewriting a container position with the name &ldquo;category.view.container&rsquo;.<\/p>\n<h4><span style=\"color: #000000;\"><strong>Move<\/strong><\/span><\/h4>\n<p>It is an ideal tool for positioning elements on a page and migrating it from one container to another.<\/p>\n<p>Consider an example of the migration of the title block, which displays the current tab in the user account in the top of the main container:<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;page xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" layout=\"2columns-left\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd\" &gt;\r\n&nbsp;&nbsp;&lt;body&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;move element=\"page.main.title\" destination=\"main\" before=\"-\"\/&gt;\r\n&nbsp;&nbsp;&lt;\/body&gt;\r\n&lt;\/page&gt;<\/pre>\n<p style=\"text-align: right;\"><em>Migration of the title block from the account-nav block to the container<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Before:<\/p>\n<p><a href=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/11\/image7.png\"><img decoding=\"async\" loading=\"lazy\" class=\"lazy aligncenter size-full wp-image-17155\" src=\"https:\/\/belvg.com\/wp-content\/uploads\/2019\/06\/pixel.png\" data-src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/11\/image7.png\" alt=\"Layout XML Directives and Their Arguments in Magento 2\" width=\"1287\" height=\"454\" title=\"Layout XML Directives and Their Arguments in Magento 2\"><\/a><\/p>\n<p>After:<\/p>\n<p><a href=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/11\/image2-1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"lazy aligncenter size-full wp-image-17156\" src=\"https:\/\/belvg.com\/wp-content\/uploads\/2019\/06\/pixel.png\" data-src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/11\/image2-1.png\" alt=\"Layout XML Directives and Their Arguments in Magento 2\" width=\"1284\" height=\"434\" title=\"Layout XML Directives and Their Arguments in Magento 2\"><\/a><\/p>\n<p>Using only one command in the layout, you can easily change the structure of the entire page, without using styles and working with templates. This instruction includes the following attributes:<\/p>\n<ul>\n<li>element &mdash; the name of the target element to send instructions;<\/li>\n<li>destination &mdash; the name of the parent element to move elements to;<\/li>\n<li>as &mdash; the name of the alias for the element is set for the element after it is moved;<\/li>\n<li>after\/before &mdash; is used for positioning inside the target parent element.<\/li>\n<\/ul>\n<h4><span style=\"color: #000000;\"><strong>Remove<\/strong><\/span><\/h4>\n<p>With it, you can remove static resource elements such as blocks with the connection of script files and styles in the &lt;head&gt; container.<\/p>\n<p>Here is an example of its application:<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;layout xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_layout.xsd\"&gt;\r\n&nbsp;&nbsp;&lt;head&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;remove src=\"css\/style-m.css\"\/&gt;\r\n&nbsp;&nbsp;&lt;\/head&gt;\r\n&lt;\/layout&gt;\r\n<\/pre>\n<p style=\"text-align: right;\"><em>deleting previously connected css mapping file&nbsp;<\/em><\/p>\n<h4><span style=\"color: #000000;\"><strong>Update<\/strong><\/span><\/h4>\n<p>It is recommended to apply it in cases when there is a need on the current page for duplication of all or most of the containers and blocks from the page layout of the parent.<\/p>\n<p>This instruction is specified at the beginning of the XML layout and is used with the handle attribute, which specifies the path and file name of the parent layout. This method is similar in its functionality to the super () method in prototype-oriented programming and performs the same functions. The target layout file will be updated recursively, i.e. sequentially.<\/p>\n<p>For example, in our project, there is a need to connect a slider with certain information on many pages. In this case, it is advisable to create a layout file with the XML markup necessary to connect the slider, which can take the following form:<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;page xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd\"&gt;\r\n&nbsp;&nbsp;&lt;body&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;referenceContainer name=\"page.wrapper\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--rev slider--&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container name=\"page.index.slider.container\" htmlTag=\"div\" htmlClass=\"page-slider-container\" before=\"main.content\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;block class=\"Nwdthemes\\Revslider\\Block\\Revslider\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;arguments&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;argument name=\"alias\" xsi:type=\"string\"&gt;Midleton&lt;\/argument&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/arguments&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/block&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/container&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/referenceContainer&gt;\r\n&nbsp;&nbsp;&lt;\/body&gt;\r\n&lt;\/page&gt;<\/pre>\n<p style=\"text-align: right;\"><em>An example of page layout with a slider connection<\/em><\/p>\n<p>In future, we can use this layout as a prototype for our inheritor files. For this, you need to specify a path to the parent layout file for the update directory in each target document.<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;page xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n&nbsp;&nbsp;&nbsp;&nbsp;xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd\"&gt;\r\n&nbsp;&nbsp;&lt;body&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;update handle=\"{name_of_handle_to_include}\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!-- CONTENT --&gt;\r\n&nbsp;&nbsp;&lt;\/body&gt;\r\n&lt;\/page&gt;<\/pre>\n<p style=\"text-align: right;\"><em>recursive layout update<\/em><\/p>\n<p>Thus, we will see our slider on each page, where the update directive will be indicated with the slider connection file as a prototype.<\/p>\n<h4><strong><span style=\"color: #000000;\">Argument<\/span><\/strong><\/h4>\n<p>The tag is used to pass arguments to the container or block.<\/p>\n<p>It has the required name and type tags. The type of the passed element is passed to type:<\/p>\n<ul>\n<li>string<\/li>\n<li>boolean<\/li>\n<li>object<\/li>\n<li>number<\/li>\n<li>null<\/li>\n<li>array<\/li>\n<\/ul>\n<p>For example, earlier in the user account, we moved our title from the header to the main container, now we need to set a custom string for the <em>myDashboard<\/em> title tab. To do this, we open the layout responsible for the <em>myDashboard<\/em> page and with the help of the action directive and the <em>setPageTitle<\/em> method we pass the string with the necessary title for our page as an argument:<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;referenceBlock name=\"page.main.title\"&gt;\r\n&nbsp;&nbsp;&lt;action method=\"setPageTitle\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;argument translate=\"true\" name=\"title\" xsi:type=\"string\"&gt;Hello, Customer!&lt;\/argument&gt;\r\n&nbsp;&nbsp;&lt;\/action&gt;\r\n&lt;\/referenceBlock&gt;<\/pre>\n<p style=\"text-align: right;\"><em>passing the parameter as a string for page-title<\/em><\/p>\n<p>We specified a string as a type and passed the required text as a string. We get what we aimed for as a result:<\/p>\n<p><a href=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/11\/image4-1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"lazy aligncenter size-full wp-image-17157\" src=\"https:\/\/belvg.com\/wp-content\/uploads\/2019\/06\/pixel.png\" data-src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/11\/image4-1.png\" alt=\"Layout XML Directives and Their Arguments in Magento 2\" width=\"1307\" height=\"603\" title=\"Layout XML Directives and Their Arguments in Magento 2\"><\/a><\/p>\n<p>The transmitted values can also be accessed from the current template file using the <strong>get()<\/strong> method. This functionality perfectly corresponds to the principles of universality and modularity in Magento. By using it, you can create a universal and dynamic template for applying in several places on our store, just like in the example of a universal layout with a slider connected to the pages.<\/p>\n<p>As an example, let&rsquo;s consider creating a template with a button rendering with any functionality on the client. We will use the same template on different pages, but depending on the requirements, we can transfer to it the CSS class, to which some style from the style sheet can be attached or even the functional load implemented on js. Here is how it will look like in the markup:<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;block class=&rdquo;Magento\\Framework\\View\\Element\\Template\" name=\"button\" template=\"Magento_Theme::buttons\/dynamic_button.phtml\" &gt;\r\n&nbsp;&nbsp;&lt;arguments&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;argument name=\"css_class\" xsi:type=\"string\"&gt;white&lt;\/argument&gt;\r\n&nbsp;&nbsp;&lt;\/arguments&gt;\r\n&lt;\/block&gt;<\/pre>\n<p style=\"text-align: right;\"><em>Passing a custom argument to the template<\/em><\/p>\n<p>To pass a class, we declare our block and specify our template to it in the template attribute, which we will consider it later. After that, we simply pass any parameters to the template as arguments, and to pass multiple parameters we use the &lt;arguments&gt; container and the &lt;argument&gt; blocks enclosed in it. We passed our class as an argument named css_class. In order to get it in the template file, you need to resort to the knowledge of PHP and write the following structure:<\/p>\n<pre class=\"lang:xhtml decode:true\">$_className = $block-&gt;getCssClass();\r\n&lt;div class=\"actions-toolbar &lt;?= $_className ?&gt;\"&gt;\r\n&nbsp;&nbsp;&lt;button class=\"action primary\"&gt;Button&lt;\/button&gt;\r\n&lt;\/div&gt;<\/pre>\n<p style=\"text-align: right;\"><em>An example of the method used to get the argument that was passed from the template<\/em><\/p>\n<p>Further, depending on the written logic, the button may accept different modifications on different pages. In this example it became white.<\/p>\n<p><a href=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/11\/joxi_screenshot_1541508734411.png\"><img decoding=\"async\" loading=\"lazy\" class=\"lazy aligncenter size-full wp-image-17160\" src=\"https:\/\/belvg.com\/wp-content\/uploads\/2019\/06\/pixel.png\" data-src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/11\/joxi_screenshot_1541508734411.png\" alt=\"Layout XML Directives and Their Arguments in Magento 2\" width=\"780\" height=\"107\" title=\"Layout XML Directives and Their Arguments in Magento 2\"><\/a><\/p>\n<p>In fact, this is the simplest example of using this functionality, which is necessary to learn the principle of its work. By using the method of passing arguments, you can do many useful things, including passing the argument that will determine the controller to process our template.<\/p>\n<p>There can be any arguments with any names and it is possible to pass not only a string but also 6 basic data types as mentioned earlier. In order to get the attributes in the template, the function takes the following form:<\/p>\n<p><em>getCssClass();<\/em><\/p>\n<p>The name parameter passed in xml in the form of &ldquo;css_class&rdquo;, takes the CamelCase form and looks like &ldquo;&#1057;ssClass&rdquo;. This method is similar to the method of passing arguments in JavaScript by using data attributes.<\/p>\n<p>Thus, Magento 2 has a huge range of tools for managing page layouts and making it easier to change page configurations and adjust it to the necessary parameters. Having mastered the principles of working with them, a Magento 2 developer opens up the possibility to customize the user interface and unified code structure more quickly and easily, so that its further support and expansion bring pleasure not only for themselves but also for subsequent developers.<\/p>\n<p>Need an expert&nbsp;<a href=\"https:\/\/belvg.com\/magento-development\" target=\"_blank\" rel=\"noopener\">Magento development team<\/a>? BelVG is here to help you.<\/p>\n\n","protected":false},"excerpt":{"rendered":"Types and purpose of XML layouts, that consists of blocks and containers","protected":false},"author":8,"featured_media":17161,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_acf_changed":false,"footnotes":""},"categories":[491,389],"tags":[],"class_list":["post-17152","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-magento-2","category-magento2-development","post_format-image"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"Find out why you need XML layouts. Learn what attributes and directives you need to manage blocks and containers in XML layouts.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Denis Guriyanov\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/belvg.com\/blog\/layout-xml-directives-and-their-arguments-in-magento-2.html\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/layout-xml-directives-and-their-arguments-in-magento-2.html#article\",\"name\":\"Layout XML Directives & Arguments in Magento 2 | BelVG Blog\",\"headline\":\"Layout XML Directives and Their Arguments in Magento 2\",\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/denis-guriyanov#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/11\\\/Magento-2-Layout-XML-Directives-and-Their-Arguments.png\",\"width\":1110,\"height\":590,\"caption\":\"Layout XML Directives and Their Arguments in Magento 2\"},\"datePublished\":\"2018-11-06T15:15:15+02:00\",\"dateModified\":\"2025-02-11T10:08:37+02:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/layout-xml-directives-and-their-arguments-in-magento-2.html#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/layout-xml-directives-and-their-arguments-in-magento-2.html#webpage\"},\"articleSection\":\"Magento 2, Magento 2 Development, Image\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/layout-xml-directives-and-their-arguments-in-magento-2.html#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"name\":\"Magento 2 Development\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"position\":2,\"name\":\"Magento 2 Development\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/layout-xml-directives-and-their-arguments-in-magento-2.html#listItem\",\"name\":\"Layout XML Directives and Their Arguments in Magento 2\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/layout-xml-directives-and-their-arguments-in-magento-2.html#listItem\",\"position\":3,\"name\":\"Layout XML Directives and Their Arguments in Magento 2\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"name\":\"Magento 2 Development\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/denis-guriyanov#author\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/denis-guriyanov\",\"name\":\"Denis Guriyanov\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/layout-xml-directives-and-their-arguments-in-magento-2.html#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cc371af19f9c419cb0c2033bd26757f6b08fce63e66c556d882502284fb0b8a1?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Denis Guriyanov\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/layout-xml-directives-and-their-arguments-in-magento-2.html#webpage\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/layout-xml-directives-and-their-arguments-in-magento-2.html\",\"name\":\"Layout XML Directives & Arguments in Magento 2 | BelVG Blog\",\"description\":\"Find out why you need XML layouts. Learn what attributes and directives you need to manage blocks and containers in XML layouts.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/layout-xml-directives-and-their-arguments-in-magento-2.html#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/denis-guriyanov#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/denis-guriyanov#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/11\\\/Magento-2-Layout-XML-Directives-and-Their-Arguments.png\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/layout-xml-directives-and-their-arguments-in-magento-2.html\\\/#mainImage\",\"width\":1110,\"height\":590,\"caption\":\"Layout XML Directives and Their Arguments in Magento 2\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/layout-xml-directives-and-their-arguments-in-magento-2.html#mainImage\"},\"datePublished\":\"2018-11-06T15:15:15+02:00\",\"dateModified\":\"2025-02-11T10:08:37+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Layout XML Directives & Arguments in Magento 2 | BelVG Blog","description":"Find out why you need XML layouts. Learn what attributes and directives you need to manage blocks and containers in XML layouts.","canonical_url":"https:\/\/belvg.com\/blog\/layout-xml-directives-and-their-arguments-in-magento-2.html","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/belvg.com\/blog\/layout-xml-directives-and-their-arguments-in-magento-2.html#article","name":"Layout XML Directives & Arguments in Magento 2 | BelVG Blog","headline":"Layout XML Directives and Their Arguments in Magento 2","author":{"@id":"https:\/\/belvg.com\/blog\/author\/denis-guriyanov#author"},"publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/11\/Magento-2-Layout-XML-Directives-and-Their-Arguments.png","width":1110,"height":590,"caption":"Layout XML Directives and Their Arguments in Magento 2"},"datePublished":"2018-11-06T15:15:15+02:00","dateModified":"2025-02-11T10:08:37+02:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/belvg.com\/blog\/layout-xml-directives-and-their-arguments-in-magento-2.html#webpage"},"isPartOf":{"@id":"https:\/\/belvg.com\/blog\/layout-xml-directives-and-their-arguments-in-magento-2.html#webpage"},"articleSection":"Magento 2, Magento 2 Development, Image"},{"@type":"BreadcrumbList","@id":"https:\/\/belvg.com\/blog\/layout-xml-directives-and-their-arguments-in-magento-2.html#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/belvg.com\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","name":"Magento 2 Development"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","position":2,"name":"Magento 2 Development","item":"https:\/\/belvg.com\/blog\/category\/magento2-development","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/layout-xml-directives-and-their-arguments-in-magento-2.html#listItem","name":"Layout XML Directives and Their Arguments in Magento 2"},"previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/layout-xml-directives-and-their-arguments-in-magento-2.html#listItem","position":3,"name":"Layout XML Directives and Their Arguments in Magento 2","previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","name":"Magento 2 Development"}}]},{"@type":"Organization","@id":"https:\/\/belvg.com\/blog\/#organization","name":"BelVG Blog","description":"Magento and Prestashop articles","url":"https:\/\/belvg.com\/blog\/"},{"@type":"Person","@id":"https:\/\/belvg.com\/blog\/author\/denis-guriyanov#author","url":"https:\/\/belvg.com\/blog\/author\/denis-guriyanov","name":"Denis Guriyanov","image":{"@type":"ImageObject","@id":"https:\/\/belvg.com\/blog\/layout-xml-directives-and-their-arguments-in-magento-2.html#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/cc371af19f9c419cb0c2033bd26757f6b08fce63e66c556d882502284fb0b8a1?s=96&d=mm&r=g","width":96,"height":96,"caption":"Denis Guriyanov"}},{"@type":"WebPage","@id":"https:\/\/belvg.com\/blog\/layout-xml-directives-and-their-arguments-in-magento-2.html#webpage","url":"https:\/\/belvg.com\/blog\/layout-xml-directives-and-their-arguments-in-magento-2.html","name":"Layout XML Directives & Arguments in Magento 2 | BelVG Blog","description":"Find out why you need XML layouts. Learn what attributes and directives you need to manage blocks and containers in XML layouts.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/belvg.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/belvg.com\/blog\/layout-xml-directives-and-their-arguments-in-magento-2.html#breadcrumblist"},"author":{"@id":"https:\/\/belvg.com\/blog\/author\/denis-guriyanov#author"},"creator":{"@id":"https:\/\/belvg.com\/blog\/author\/denis-guriyanov#author"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/11\/Magento-2-Layout-XML-Directives-and-Their-Arguments.png","@id":"https:\/\/belvg.com\/blog\/layout-xml-directives-and-their-arguments-in-magento-2.html\/#mainImage","width":1110,"height":590,"caption":"Layout XML Directives and Their Arguments in Magento 2"},"primaryImageOfPage":{"@id":"https:\/\/belvg.com\/blog\/layout-xml-directives-and-their-arguments-in-magento-2.html#mainImage"},"datePublished":"2018-11-06T15:15:15+02:00","dateModified":"2025-02-11T10:08:37+02:00"},{"@type":"WebSite","@id":"https:\/\/belvg.com\/blog\/#website","url":"https:\/\/belvg.com\/blog\/","name":"BelVG Blog","description":"Magento and Prestashop articles","inLanguage":"en-US","publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"}}]}},"aioseo_meta_data":{"post_id":"17152","title":"Layout XML Directives &amp; Arguments in Magento 2 | #site_title","description":"Find out why you need XML layouts. Learn what attributes and directives you need to manage blocks and containers in XML layouts.","keywords":[{"label":"magento 2 layout xml","value":"magento 2 layout xml"},{"label":"magento 2 layout xml arguments","value":"magento 2 layout xml arguments"},{"label":"magento 2 layout update xml","value":"magento 2 layout update xml"},{"label":"magento 2 layout xml directives","value":"magento 2 layout xml directives"}],"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-11-03 18:37:01","updated":"2026-11-03 18:37:01"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/category\/magento2-development\" title=\"Magento 2 Development\">Magento 2 Development<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tLayout XML Directives and Their Arguments in Magento 2\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/belvg.com\/blog\/"},{"label":"Magento 2 Development","link":"https:\/\/belvg.com\/blog\/category\/magento2-development"},{"label":"Layout XML Directives and Their Arguments in Magento 2","link":"https:\/\/belvg.com\/blog\/layout-xml-directives-and-their-arguments-in-magento-2.html"}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/17152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/comments?post=17152"}],"version-history":[{"count":2,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/17152\/revisions"}],"predecessor-version":[{"id":28721,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/17152\/revisions\/28721"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media\/17161"}],"wp:attachment":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media?parent=17152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/categories?post=17152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/tags?post=17152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}