1

As i am new to Magento Developement i came up with the following Question:

Should i edit the phtml files directly or is it better to add Containers and Move Elements within the Default.xml?

<referenceContainer name="header.container">
          <container name="header.cwrapper" htmlTag="div" htmlClass="headroom-wrapper">
            <container name="header.sticky" htmlTag="div" htmlId="chrome-sticky-header" htmlClass="headroom">
              <container name="headroom.main" htmlTag="div" htmlClass="headroom-main">

              </container>
            </container>
          </container>

        </referenceContainer>
        <move element="header-wrapper" destination="headroom.main" />

Instead of Processing Container after Container and Moving the Wrapper into the new Containers, wouldn't it be smarter to do it directly within the phtml?

Magento 2 layout XML <move /> performance

1

While this might be tough to truly accept as an "Answer" as it will always be highly opinionated, I believe and follow the XML approach to updating. While updating PHTML files is likely faster, I like having my template files fall back to "base". As an example, if you edited the Header PHTML, but they added a new Magento feature such as "CMS Header Navigation" ok dreaming, you'd never know the feature existed, because your theme may have removed the call that injected this new piece. IMHO, XML allows you to quickly recognize your changes over stock, so when you upgrade you can review quickly to see if there is anything at risk.

Hope this answers! Please feel free to respond if you have any questions.

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.