TransWikia.com

Moving content of custom header Magento 2

Magento Asked by Aissa Mahdi on December 30, 2021

This is how the header is displayed

I created a custom header and called it in the default.xml
this is the code

<referenceContainer name="header.container">
    <block class="MagentoFrameworkViewElementTemplate" name="custom_header" as="custom_header" template="Magento_Theme::html/customheader.phtml"  before="-" />
</referenceContainer>

        <move element="minicart" destination="custom_header"/>
        <move element="top.search" destination="custom_header"/>
        <move element="logo" as="logo" destination="custom_header"/>

I want to move the content to the empty black area
I’m using Magento 2.2.5
Thanks

One Answer

Welcome to community.

If you want to add a custom Reference Container You can add following code at

app/design/frontend/[Package]/[theme]/Magento_Theme/layout/default.xml

<?xml version="1.0"?>
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">

<referenceContainer name="header.container">
    <container name="custom_header" as="custom_header" label="My Custom Header" htmlTag="div" htmlClass="my-container" before="page.top"/>
</referenceContainer>

    <move element="minicart" destination="custom_header"/>
    <move element="top.search" destination="custom_header"/>
    <move element="logo" as="logo" destination="custom_header"/>

Above code will create a new container and move element to that.

Note For adding new container you can use after before.

Answered by Pawan on December 30, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP