0

I'm trying to move the header.links from header.panel to header-wrapper without removing the header.links from the mobile menu (store.links).

I tried it with a referenceContainer and the move command in theme/Magento_Customer/layout/default.xml

<referenceContainer name="header-wrapper">
    <block class="Magento\Customer\Block\Account\Customer" name="customer" template="account/customer.phtml" before="-"/>
</referenceContainer>

OR

<move element="header.links" destination="header-wrapper"/>

Can someone tell me how to do it right?

2 Answers 2

0

Add a custom block to reference-container header-wrapper and add/copy the children from header.links to your new header.links.custom block.

new header.link.custom block:

 <referenceContainer name="header-wrapper">           
        <block class="Magento\Framework\View\Element\Html\Links" name="header.links.custom" before="-">
            <arguments>
                <argument name="css_class" xsi:type="string">header links</argument>
            </arguments>
        </block>
 </referenceContainer>

copy/insert children (give them unique names, just added "-custom" here)

  <referenceBlock name="header.links.custom">
        <block class="Magento\Customer\Block\Account\Customer" name="customer-custom" template="Magento_Customer::account/customer.phtml" before="-"/>
        <block class="Magento\Customer\Block\Account\AuthorizationLink" name="authorization-link-login-custom" template="Magento_Customer::account/link/authorization.phtml">
            <arguments>
                <argument name="sortOrder" xsi:type="number">10</argument>
            </arguments>
        </block>
  </referenceBlock>

That should do the trick, maybe you have to hide the header.links.custom block with css in your mobile view.

0

You can move header links using below code in theme/Magento_Theme/layout/default.xml

<move element="header.panel" destination="header-wrapper" after="-"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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