Skip to content

Instantly share code, notes, and snippets.

@wcodex
Created October 3, 2013 05:11
Show Gist options
  • Save wcodex/6805282 to your computer and use it in GitHub Desktop.
Save wcodex/6805282 to your computer and use it in GitHub Desktop.
How to add and customize the search box in Magento
//Available at [your-theme]/template/categorysearch/form.mini.phtml
<?php
$catalogSearchHelper = $this->helper('catalogsearch');
?>
<form id="search_mini_form" action="<?php echo $catalogSearchHelper->getResultUrl() ?>" method="get">
<div class="form-search">
<div class="container">
<input id="search" type="text" name="<?php echo $catalogSearchHelper->getQueryParamName() ?>" value="<?php echo $catalogSearchHelper->getEscapedQueryText() ?>" class="blink" maxlength="<?php echo $catalogSearchHelper->getMaxQueryLength();?>" />
</div>
<button type="submit" title="<?php echo $this->__('Search') ?>" class="search-button"><span><span><?php echo $this->__('Search') ?></span></span></button>
<div id="search_autocomplete" class="search-autocomplete"></div>
<script type="text/javascript">
//<![CDATA[
var searchForm = new Varien.searchForm('search_mini_form', 'search', '<?php echo $this->__('Search entire store here...') ?>');
searchForm.initAutocomplete('<?php echo $catalogSearchHelper->getSuggestUrl() ?>', 'search_autocomplete');
//]]>
</script>
</div>
</form
//Code to add search box
<?php echo $this->getChildHtml('topSearch') ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment