0

I want to edit default search bar in Magento 2. What I would like to have is to display the search icon and when the customer clicks the icon I want to show the search bar.

To do that, where to update the code?

Can anyone please guide me?

2
  • Can you please post demo image or something else? Commented Oct 4, 2019 at 6:02
  • Edit this file: vendor/magento/module-catalog-search/view/frontend/templates/result.phtml Commented Oct 4, 2019 at 7:49

1 Answer 1

0

You need to do some thing like this one.

  1. Create one custom extension and overide magento 2 default search file into extension. for that one create the default.xml file at following location.

app\code\Vendor\Extension\view\frontend\layout\default.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="header-wrapper">
            <referenceBlock name="top.search">
                <action method="setTemplate">
                    <argument name="template" xsi:type="string">Vendor_Extension::form.mini.phtml</argument>
                </action>
            </referenceBlock>
        </referenceContainer>
    </body>
</page>
  1. now copy form.mini.phtml phtml from

vendor\magento\module-search\view\frontend\templates\form.mini.phtml

To

app\code\Vendor\Extension\view\frontend\templates\form.mini.phtml

Now you can change, what every you want to do here.

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.