I'm trying to understand Magento's html building process. Currently I'm stuck at this file: https://github.com/magento/magento2/blob/develop/app/code/Magento/Theme/view/frontend/layout/default.xml

Here in line 19 you will find this:

   <referenceBlock name="top.links">
        <block class="Magento\Theme\Block\Html\Header" name="header" as="header" before="-">
                <argument name="show_part" xsi:type="string">welcome</argument>

And this at line 33:

<referenceContainer name="header.container">
                <!-- line 43 below -->
                <block class="Magento\Framework\View\Element\Html\Links" name="top.links">
                        <argument name="css_class" xsi:type="string">header links</argument>

As far as I get this does the following:

  • it will create an "ul" element (due to the code in the class Links) referenced as "top.links" with css classes "header links"
  • it will add a "header" element referenced as "header" at the top (because of the before) of the ul-Element that is referenced as "top.links"
    • Stuff in those top links is added elsewhere, like in the customer module

What I don't get is this: if I cut the first block <referenceBlock name="top.links">... starting from line 19 to line 25 and paste it below the code in line 33, say below line 58. Why does the generated element in the html output also move somewhere else and will not be generated at the top of the container but at the bottom?

Your Answer

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

Browse other questions tagged or ask your own question.