Skip to content

Commit b381e52

Browse files
committed
Merge branch 'master' into develop
2 parents bc6c370 + 8456831 commit b381e52

File tree

8 files changed

+44
-4
lines changed

8 files changed

+44
-4
lines changed

code/Helper/Config.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,23 @@ class Algolia_Algoliasearch_Helper_Config extends Mage_Core_Helper_Abstract
5353
const CUSTOMER_GROUPS_ENABLE = 'algoliasearch/advanced/customer_groups_enable';
5454
const MAKE_SEO_REQUEST = 'algoliasearch/advanced/make_seo_request';
5555
const REMOVE_BRANDING = 'algoliasearch/advanced/remove_branding';
56+
const AUTOCOMPLETE_SELECTOR = 'algoliasearch/advanced/autocomplete_selector';
5657

5758
const SHOW_OUT_OF_STOCK = 'cataloginventory/options/show_out_of_stock';
5859
const LOGGING_ENABLED = 'dev/log/active';
5960

6061
protected $_productTypeMap = array();
6162

63+
public function isDefaultSelector($storeId = null)
64+
{
65+
return '.algolia-search-input' === $this->getAutocompleteSelector($storeId);
66+
}
67+
68+
public function getAutocompleteSelector($storeId = null)
69+
{
70+
return Mage::getStoreConfig(self::AUTOCOMPLETE_SELECTOR, $storeId);
71+
}
72+
6273
public function getNumberOfQueriesSuggestions($storeId = null)
6374
{
6475
return Mage::getStoreConfig(self::NB_OF_QUERIES_SUGGESTIONS, $storeId);

code/Model/Observer.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ public function useAlgoliaSearchPopup(Varien_Event_Observer $observer)
5454
if ($this->config->isPopupEnabled() || $this->config->isInstantEnabled())
5555
{
5656
$observer->getLayout()->getUpdate()->addHandle('algolia_search_handle');
57+
58+
if ($this->config->isDefaultSelector())
59+
{
60+
$observer->getLayout()->getUpdate()->addHandle('algolia_search_handle_with_topsearch');
61+
}
62+
else
63+
{
64+
$observer->getLayout()->getUpdate()->addHandle('algolia_search_handle_no_topsearch');
65+
}
5766
}
5867
}
5968
}

code/etc/config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
<partial_update>0</partial_update>
188188
<make_seo_request>1</make_seo_request>
189189
<remove_branding>0</remove_branding>
190+
<autocomplete_selector>.algolia-search-input</autocomplete_selector>
190191
</advanced>
191192
<product_map>
192193
<!--

code/etc/system.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,15 @@
629629
<show_in_store>1</show_in_store>
630630
<comment>Choose here if the algolia logo is added to the drop-down template.</comment>
631631
</remove_branding>
632+
<autocomplete_selector translate="label comment">
633+
<label>Search input DOM Selector</label>
634+
<frontend_type>text</frontend_type>
635+
<sort_order>50</sort_order>
636+
<show_in_default>1</show_in_default>
637+
<show_in_website>1</show_in_website>
638+
<show_in_store>1</show_in_store>
639+
<comment>If you don't have the top.search block you can specify the selector of your search input here to use it. Default value is .algolia-search-input</comment>
640+
</autocomplete_selector>
632641
</fields>
633642
</advanced>
634643
</groups>

design/frontend/layout/algoliasearch.xml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,19 @@
1818
<reference name="before_body_end">
1919
<block type="core/template" template="algoliasearch/frontjs.phtml"/>
2020
</reference>
21-
<reference name="top.search">
22-
<action method="setTemplate"><template>algoliasearch/topsearch.phtml</template></action>
23-
</reference>
2421
<reference name="content">
2522
<block type="core/template" before="content" template="algoliasearch/beforecontent.phtml"/>
2623
</reference>
24+
2725
</algolia_search_handle>
26+
<algolia_search_handle_with_topsearch>
27+
<reference name="top.search">
28+
<action method="setTemplate"><template>algoliasearch/topsearch.phtml</template></action>
29+
</reference>
30+
</algolia_search_handle_with_topsearch>
31+
<algolia_search_handle_no_topsearch>
32+
<reference name="head">
33+
<block type="core/template" template="algoliasearch/topsearch.phtml"/>
34+
</reference>
35+
</algolia_search_handle_no_topsearch>
2836
</layout>

design/frontend/template/beforetopsearch.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ if ($config->isInstantEnabled() && $isSearchPage) {
9797
},
9898
autocomplete: {
9999
enabled: <?php echo $config->isAutoCompleteEnabled() ? "true" : "false"; ?>,
100-
selector: '.algolia-search-input',
100+
selector: '<?php echo $config->getAutocompleteSelector(); ?>',
101101
sections: <?php echo json_encode($config->getAutocompleteSections()); ?>,
102102
nbOfProductsSuggestions: '<?php echo $config->getNumberOfProductsSuggestions(); ?>',
103103
nbOfCategoriesSuggestions: '<?php echo $config->getNumberOfCategoriesSuggestions(); ?>',

design/frontend/template/topsearch.phtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ $placeholder = $this->__('Search for products, categories, ...');
4646

4747
?>
4848

49+
<?php if ($config->isDefaultSelector()): ?>
4950
<form id="search_mini_form" action="<?php echo $catalogSearchHelper->getResultUrl() ?>" method="get">
5051
<div id="algolia-searchbox">
5152
<label for="search"><?php echo $this->__('Search:') ?></label>
@@ -60,6 +61,7 @@ $placeholder = $this->__('Search for products, categories, ...');
6061
</svg>
6162
</div>
6263
</form>
64+
<?php endif; ?>
6365

6466
<!--
6567
//================================

releases/algoliasearch-1.5.0.tgz

275 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)