magento / community-features

Magento Features Development is an Initiative to Allows Community Memebers Join to Development of Magento Features
46 stars 18 forks source link

'header' block name is ambiguous #33

Open magento-engcom-team opened 6 years ago

magento-engcom-team commented 6 years ago

Preconditions

  1. Magento Enterprise 2.1.0

    Steps to reproduce

  2. Add custom content to html/header.phtml for theme, or perform some sort of action on header block in XML via referenceBlock.

    Expected result

  3. One would expect, based on the naming convention used here, that the affected block would be the page header.

    Actual result

  4. This is actually a block that outputs a welcome message within the header.

I'm not entirely certain if this is the correct place for this discussion. Apologies if it's not.

I'm putting together a blank theme at the moment. This naming issue causes me concern because I am finding it difficult to put together something easy to use. It would be nice if I could use the name header.phtml for my template and the block name header for my page header, as I think this is the most intuituve. I cannot do this however because there is a 'welcome' block in Magento with a template reference hard-coded (not via XML) to my intended template name, and with its block name set to header

Maybe a different name for this block, such as welcome-message, would be more appropriate?

File where template name is set: vendor/magento/module-theme/Block/Html/Header.php

XML for block, in default.xml:

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

Original Report: https://github.com/magento/magento2/issues/6577 by @tommypyatt