Move blocks to other container how to

  • Being newby I look for a workaround to move Sign in and Store switcher from header.panel to header.container. I just tried this code but won't work

    <referenceContainer name="header.container">
            <referenceBlock  class="Magento\Store\Block\Switcher" name="store.settings.language" template="switch/languages.phtml"> </referenceBlock>
  • Tyler Craft

    Tyler Craft Correct answer

    5 years ago

    There is a new move node in the layout XML that we have access to in M2. This node sets the declared block or container element as a child of another element in the specified order.


    <move element="" destination="name.of.destination.element" as="new_alias" after="name.of.element.after" before="name.of.element.before"/>

    In the example you provided before you should just be able to call:

    <move element="store.settings.language" destination="header.container" as="store_settings_language"/>

    More information in the official M2 docs on <move> here:

License under CC-BY-SA with attribution

Content dated before 7/24/2021 11:53 AM