5

In Magento 2, layout handle XML files introduced a few new top level tags (body, head, etc)

<page>
    <body>
        <!-- ... -->
    </body>
    <head>
        <!-- ... -->
    </head>
</page>

These tags trigger extra programatic node processing when Magento is loading and parsing the layout update XML files. For example, the body tag's extra processing happens in the following files

./lib/internal/Magento/Framework/View/Page/Config/Generator/Body.php
./lib/internal/Magento/Framework/View/Page/Config/Reader/Body.php

From the point of view of a module or theme developer using the system -- what are these new top level tags called? i.e. in Magento 1, the top level tags (under the root tag) were layout handles, and handles contained block and reference instructions.

i.e. In Magento 2, each individual module layout handle XML file name is a handle, each top level tag (under the root page tag) is called a [BLANK], and [BLANK] tags contain referenceBlock and referenceContainer instructions.

What, in Magento 2 parlance, is "[BLANK]"

  • Does it need a special name? Wouldn't it suffice to just call them page elements? – Kristof at Fooman Sep 14 '15 at 1:20
  • According to devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/… they seem to refer to it as <body> section and <head> section – Renon Stewart Sep 14 '15 at 1:58
  • @fooman Giving important elements of a system names makes it easier to talk about the system, teach the system, and reason about the system. Example -- "The string you pass into the getModel, helper or createBlock methods that Magento uses to lookup a PHP class name" vs. "The class alias". Which would you rather read in a tutorial over and over again? – Alan Storm Sep 14 '15 at 2:12
  • @R.S. I'm not sure that description completely covers is -- it answers the question for the specific body and head tags, but Magento 2 also processes several other top level nodes in layout files, like html, move, uiComponent, etc. – Alan Storm Sep 14 '15 at 3:08
3

There is no special name at present. <body> holds content intended for the body of the page, <head> holds content intended for the head of the page. The tags were added to try to help conceptual separation. You put blocks and containers in the body, you put CSS references in the <head>.

So <body> element and <head> element?

  • Thank you -- marking this a "best answer" for now, as there's not an answer. Grain of salt, etc, but If possible, I'd pressure the team behind the layout DSL to formalize a naming convention and structure. From the point of view of a designer/developer using this system, having layout XML file where sometimes the first child of the root tag is an action and other times it's one of these special parsing context tags is level of abstraction too far. If the system can't be explained it's likely to be abused. – Alan Storm Sep 15 '15 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.