Question

How do i add a simple catalog search form on a CMS-page?

Is there a widget code or something for this, just an easy way to implement it anywhere.

Était-ce utile?

La solution

There is no widget available for this, but pasting the following code into a CMS page or Static Block will allow you to put a search block where you want to have it:

<form id="search_mini_form_cms" action="{{store url='catalogsearch/result'}}" method="get">
    <div class="input-box">
        <label for="search_cms">Search:</label>
        <input id="search_cms" type="search" name="q" value="" class="input-text required-entry" maxlength="128" placeholder="Search entire store here..." autocomplete="off">
        <button type="submit" title="Search" class="button search-button"><span><span>Search</span></span></button>
    </div>

    <div id="search_cms_autocomplete" class="search-autocomplete" style="display: none;"></div>
    <script type="text/javascript">
    //<![CDATA[
        var cmsSearchForm = new Varien.searchForm('search_mini_form_cms', 'search_cms', '');
        cmsSearchForm.initAutocomplete('{{store url='catalogsearch/ajax/suggest'}}', 'search_cms_autocomplete');
    //]]>
    </script>
</form>

You may need to add some CSS to display it to your needs.

Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top