0

In which file path <header> tag is available in Magento2? I need to customize the default header of the Magneto Luma theme.

Updated: I already checked header.phtml file but didn't find header tag.

Updated 1: I need to add below HTML inside the header.

i need to add inside the header tag..

<div class="headerTop">
                <div class="container-fluid">
                    <div class="row">
                        <div class="logo">
                            <a href="index.html">
                                <img src="img/logo.png">
                            </a>
                        </div>
                        <div class="search_block">
                            <form>
                                <div class="form-group search_box">
                                    <input type="text" class="form-control" id="" placeholder="Search the store">
                                </div>
                            </form>
                        </div>
                        <div class="d-flex userAction">
                            <ul class="topNav">
                                <li>
                                    Currency :
                                    <select class="select_currency">
                                        <option>INR</option>
                                    </select>
                                </li>
                                <li class="d-md-block d-none">                                  
                                    <select class="select_currency">
                                        <option>Select Language</option>
                                    </select>
                                </li>
                                <li>
                                    <a href=""><img src="img/paint_ic.png" alt=""></a>
                                </li>
                                <li>
                                    <a href=""><img src="img/user_ic.png" alt=""></a>
                                </li>
                                <li>
                                    <a href=""><img src="img/fav_ic.png" alt=""></a>
                                </li>
                                <li>
                                    <a href="cart.php"><img src="img/cart_ic.png" alt=""></a>
                                </li>
                            </ul>
                            <div class="navbar-dark d-flex justify-content-end d-lg-none">
                                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                                    <span class="navbar-toggler-icon"></span>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
7
  • ok, you want to edit header for luma theme right? Commented Jan 31, 2020 at 6:43
  • yes, I want to edit the header of luma. I have already overridden the luma theme. Commented Jan 31, 2020 at 6:46
  • so bro let me know what you want to add Commented Jan 31, 2020 at 6:47
  • because you can not directly find it. Commented Jan 31, 2020 at 6:48
  • updated my question, I will dynamic all things but where to add above HTML. Commented Jan 31, 2020 at 6:52

2 Answers 2

0

There are many ways but here I can share one simple way to override vendor. 1.please override vendor/magento/module-theme/view/frontend/layout/default.xml code here replace below code

<container name="header.panel.wrapper" htmlClass="panel wrapper" htmlTag="div" before="-">




                <container name="header.panel" label="Page Header Panel" htmlTag="div" htmlClass="panel header">
                    <block class="Magento\Framework\View\Element\Template" name="skip_to_content" template="Magento_Theme::html/skip.phtml">
                        <arguments>
                            <argument name="target" xsi:type="string">contentarea</argument>
                            <argument name="label" translate="true" xsi:type="string">Skip to Content</argument>
                        </arguments>
                    </block>
                    <block class="Magento\Store\Block\Switcher" name="store_language" as="store_language" template="Magento_Store::switch/languages.phtml">
                        <arguments>
                            <argument name="view_model" xsi:type="object">Magento\Store\ViewModel\SwitcherUrlProvider</argument>
                        </arguments>
                    </block>
                    <block class="Magento\Customer\Block\Account\Navigation" name="top.links">
                        <arguments>
                            <argument name="css_class" xsi:type="string">header links</argument>
                        </arguments>
                    </block>
                </container>
            </container>

to

<container name="header.panel.wrapper" htmlClass="panel wrapper" htmlTag="div" before="-">

                <container name="test_block" label="Home DiscountBanner" as="test_block" htmlTag="div" htmlClass="test_block">
                    <block class="Magento\Framework\View\Element\Template" name="home_discount_banner_template" template="Magento_Theme::html/header/test_block.phtml">
                </block>
                 </container>


                <container name="header.panel" label="Page Header Panel" htmlTag="div" htmlClass="panel header">
                    <block class="Magento\Framework\View\Element\Template" name="skip_to_content" template="Magento_Theme::html/skip.phtml">
                        <arguments>
                            <argument name="target" xsi:type="string">contentarea</argument>
                            <argument name="label" translate="true" xsi:type="string">Skip to Content</argument>
                        </arguments>
                    </block>
                    <block class="Magento\Store\Block\Switcher" name="store_language" as="store_language" template="Magento_Store::switch/languages.phtml">
                        <arguments>
                            <argument name="view_model" xsi:type="object">Magento\Store\ViewModel\SwitcherUrlProvider</argument>
                        </arguments>
                    </block>
                    <block class="Magento\Customer\Block\Account\Navigation" name="top.links">
                        <arguments>
                            <argument name="css_class" xsi:type="string">header links</argument>
                        </arguments>
                    </block>
                </container>
            </container>
  1. please add one file in vendor/magento/module-theme/view/frontend/templates/html/header/test_block.phtml
<div class="headerTop">
                <div class="container-fluid">
                    <div class="row">
                        <div class="logo">
                            <a href="index.html">
                                <img src="img/logo.png">
                            </a>
                        </div>
                        <div class="search_block">
                            <form>
                                <div class="form-group search_box">
                                    <input type="text" class="form-control" id="" placeholder="Search the store">
                                </div>
                            </form>
                        </div>
                        <div class="d-flex userAction">
                            <ul class="topNav">
                                <li>
                                    Currency :
                                    <select class="select_currency">
                                        <option>INR</option>
                                    </select>
                                </li>
                                <li class="d-md-block d-none">                                  
                                    <select class="select_currency">
                                        <option>Select Language</option>
                                    </select>
                                </li>
                                <li>
                                    <a href=""><img src="img/paint_ic.png" alt=""></a>
                                </li>
                                <li>
                                    <a href=""><img src="img/user_ic.png" alt=""></a>
                                </li>
                                <li>
                                    <a href=""><img src="img/fav_ic.png" alt=""></a>
                                </li>
                                <li>
                                    <a href="cart.php"><img src="img/cart_ic.png" alt=""></a>
                                </li>
                            </ul>
                            <div class="navbar-dark d-flex justify-content-end d-lg-none">
                                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                                    <span class="navbar-toggler-icon"></span>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

and you will make the cache clear and check it. this is for static you need to change hide some blocks ok.

Hope it works. Thanks

0

You can find header tag in vendor\magento\module-theme\view\frontend\page_layout\1column.xml

<container name="header.container" as="header_container" label="Page Header Container" htmlTag="header" htmlClass="page-header" before="main.content"/>

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.