Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
maxiloc committed Dec 18, 2015
2 parents bc6c370 + 8456831 commit b381e52
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 4 deletions.
11 changes: 11 additions & 0 deletions code/Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,23 @@ class Algolia_Algoliasearch_Helper_Config extends Mage_Core_Helper_Abstract
const CUSTOMER_GROUPS_ENABLE = 'algoliasearch/advanced/customer_groups_enable';
const MAKE_SEO_REQUEST = 'algoliasearch/advanced/make_seo_request';
const REMOVE_BRANDING = 'algoliasearch/advanced/remove_branding';
const AUTOCOMPLETE_SELECTOR = 'algoliasearch/advanced/autocomplete_selector';

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

protected $_productTypeMap = array();

public function isDefaultSelector($storeId = null)
{
return '.algolia-search-input' === $this->getAutocompleteSelector($storeId);
}

public function getAutocompleteSelector($storeId = null)
{
return Mage::getStoreConfig(self::AUTOCOMPLETE_SELECTOR, $storeId);
}

public function getNumberOfQueriesSuggestions($storeId = null)
{
return Mage::getStoreConfig(self::NB_OF_QUERIES_SUGGESTIONS, $storeId);
Expand Down
9 changes: 9 additions & 0 deletions code/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ public function useAlgoliaSearchPopup(Varien_Event_Observer $observer)
if ($this->config->isPopupEnabled() || $this->config->isInstantEnabled())
{
$observer->getLayout()->getUpdate()->addHandle('algolia_search_handle');

if ($this->config->isDefaultSelector())
{
$observer->getLayout()->getUpdate()->addHandle('algolia_search_handle_with_topsearch');
}
else
{
$observer->getLayout()->getUpdate()->addHandle('algolia_search_handle_no_topsearch');
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions code/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
<partial_update>0</partial_update>
<make_seo_request>1</make_seo_request>
<remove_branding>0</remove_branding>
<autocomplete_selector>.algolia-search-input</autocomplete_selector>
</advanced>
<product_map>
<!--
Expand Down
9 changes: 9 additions & 0 deletions code/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,15 @@
<show_in_store>1</show_in_store>
<comment>Choose here if the algolia logo is added to the drop-down template.</comment>
</remove_branding>
<autocomplete_selector translate="label comment">
<label>Search input DOM Selector</label>
<frontend_type>text</frontend_type>
<sort_order>50</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<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>
</autocomplete_selector>
</fields>
</advanced>
</groups>
Expand Down
14 changes: 11 additions & 3 deletions design/frontend/layout/algoliasearch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@
<reference name="before_body_end">
<block type="core/template" template="algoliasearch/frontjs.phtml"/>
</reference>
<reference name="top.search">
<action method="setTemplate"><template>algoliasearch/topsearch.phtml</template></action>
</reference>
<reference name="content">
<block type="core/template" before="content" template="algoliasearch/beforecontent.phtml"/>
</reference>

</algolia_search_handle>
<algolia_search_handle_with_topsearch>
<reference name="top.search">
<action method="setTemplate"><template>algoliasearch/topsearch.phtml</template></action>
</reference>
</algolia_search_handle_with_topsearch>
<algolia_search_handle_no_topsearch>
<reference name="head">
<block type="core/template" template="algoliasearch/topsearch.phtml"/>
</reference>
</algolia_search_handle_no_topsearch>
</layout>
2 changes: 1 addition & 1 deletion design/frontend/template/beforetopsearch.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ if ($config->isInstantEnabled() && $isSearchPage) {
},
autocomplete: {
enabled: <?php echo $config->isAutoCompleteEnabled() ? "true" : "false"; ?>,
selector: '.algolia-search-input',
selector: '<?php echo $config->getAutocompleteSelector(); ?>',
sections: <?php echo json_encode($config->getAutocompleteSections()); ?>,
nbOfProductsSuggestions: '<?php echo $config->getNumberOfProductsSuggestions(); ?>',
nbOfCategoriesSuggestions: '<?php echo $config->getNumberOfCategoriesSuggestions(); ?>',
Expand Down
2 changes: 2 additions & 0 deletions design/frontend/template/topsearch.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ $placeholder = $this->__('Search for products, categories, ...');

?>

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

<!--
//================================
Expand Down
Binary file modified releases/algoliasearch-1.5.0.tgz
Binary file not shown.

0 comments on commit b381e52

Please sign in to comment.