Version Notes
Provides full ajax catalog layered navigation on product listing page as well as search results page.
Download this release
Release Info
Developer | Hardik Gajjar |
Extension | HardikAjaxNav |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/local/Hardik/Ajaxnav/controllers/Catalog/CategoryController.php +84 -0
- app/code/local/Hardik/Ajaxnav/controllers/Catalog/Product/CompareController.php +40 -0
- app/code/local/Hardik/Ajaxnav/controllers/Catalogsearch/ResultController.php +78 -0
- app/code/local/Hardik/Ajaxnav/etc/config.xml +86 -0
- app/design/frontend/base/default/layout/ajaxnav.xml +82 -0
- app/design/frontend/base/default/template/ajaxnav/ajax.phtml +6 -0
- app/etc/modules/Hardik_Ajaxnav.xml +14 -0
- js/ajaxnav/ajaxnav.js +108 -0
- package.xml +18 -0
app/code/local/Hardik/Ajaxnav/controllers/Catalog/CategoryController.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Category controller
|
4 |
+
*
|
5 |
+
* @category Hardik
|
6 |
+
* @package Hardik_Ajaxnav
|
7 |
+
*/
|
8 |
+
require_once 'Mage/Catalog/controllers/CategoryController.php';
|
9 |
+
|
10 |
+
class Hardik_Ajaxnav_Catalog_CategoryController extends Mage_Catalog_CategoryController
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Category view action
|
14 |
+
*/
|
15 |
+
public function viewAction()
|
16 |
+
{
|
17 |
+
if ($category = $this->_initCatagory()) {
|
18 |
+
$design = Mage::getSingleton('catalog/design');
|
19 |
+
$settings = $design->getDesignSettings($category);
|
20 |
+
|
21 |
+
// apply custom design
|
22 |
+
if ($settings->getCustomDesign()) {
|
23 |
+
$design->applyCustomDesign($settings->getCustomDesign());
|
24 |
+
}
|
25 |
+
|
26 |
+
Mage::getSingleton('catalog/session')->setLastViewedCategoryId($category->getId());
|
27 |
+
|
28 |
+
$update = $this->getLayout()->getUpdate();
|
29 |
+
$update->addHandle('default');
|
30 |
+
|
31 |
+
if (!$category->hasChildren()) {
|
32 |
+
$update->addHandle('catalog_category_layered_nochildren');
|
33 |
+
}
|
34 |
+
|
35 |
+
$this->addActionLayoutHandles();
|
36 |
+
$update->addHandle($category->getLayoutUpdateHandle());
|
37 |
+
$update->addHandle('CATEGORY_' . $category->getId());
|
38 |
+
|
39 |
+
/* custom code start */
|
40 |
+
//$isAjax = $this->getRequest()->getParam('ajax');
|
41 |
+
if ($this->getRequest()->isXmlHttpRequest()) {
|
42 |
+
$update->removeHandle('catalog_category_layered');
|
43 |
+
$update->removeHandle('catalog_category_default');
|
44 |
+
$update->addHandle('catalog_category_ajax');
|
45 |
+
if ($category->getIsAnchor()) {
|
46 |
+
$update->addHandle('catalog_category_ajax_layered');
|
47 |
+
} else {
|
48 |
+
$update->addHandle('catalog_category_ajax_default');
|
49 |
+
}
|
50 |
+
}
|
51 |
+
/* custom code end */
|
52 |
+
|
53 |
+
$this->loadLayoutUpdates();
|
54 |
+
|
55 |
+
// apply custom layout update once layout is loaded
|
56 |
+
if ($layoutUpdates = $settings->getLayoutUpdates()) {
|
57 |
+
if (is_array($layoutUpdates)) {
|
58 |
+
foreach($layoutUpdates as $layoutUpdate) {
|
59 |
+
$update->addUpdate($layoutUpdate);
|
60 |
+
}
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
$this->generateLayoutXml()->generateLayoutBlocks();
|
65 |
+
|
66 |
+
// apply custom layout (page) template once the blocks are generated
|
67 |
+
if ($settings->getPageLayout()) {
|
68 |
+
$this->getLayout()->helper('page/layout')->applyTemplate($settings->getPageLayout());
|
69 |
+
}
|
70 |
+
|
71 |
+
if ($root = $this->getLayout()->getBlock('root')) {
|
72 |
+
$root->addBodyClass('categorypath-' . $category->getUrlPath())
|
73 |
+
->addBodyClass('category-' . $category->getUrlKey());
|
74 |
+
}
|
75 |
+
|
76 |
+
$this->_initLayoutMessages('catalog/session');
|
77 |
+
$this->_initLayoutMessages('checkout/session');
|
78 |
+
$this->renderLayout();
|
79 |
+
}
|
80 |
+
elseif (!$this->getResponse()->isRedirect()) {
|
81 |
+
$this->_forward('noRoute');
|
82 |
+
}
|
83 |
+
}
|
84 |
+
}
|
app/code/local/Hardik/Ajaxnav/controllers/Catalog/Product/CompareController.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Catalog comapare controller
|
4 |
+
* referer urlescape after add to compare issue fix
|
5 |
+
*
|
6 |
+
* @category Hardik
|
7 |
+
* @package Hardik_Ajaxnav
|
8 |
+
*/
|
9 |
+
|
10 |
+
require_once 'Mage/Catalog/controllers/Product/CompareController.php';
|
11 |
+
|
12 |
+
class Hardik_Ajaxnav_Catalog_Product_CompareController extends Mage_Catalog_Product_CompareController
|
13 |
+
{
|
14 |
+
/**
|
15 |
+
* Identify referer url via all accepted methods (HTTP_REFERER, regular or base64-encoded request param)
|
16 |
+
*
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
protected function _getRefererUrl()
|
20 |
+
{
|
21 |
+
$refererUrl = $this->getRequest()->getServer('HTTP_REFERER');
|
22 |
+
if ($url = $this->getRequest()->getParam(self::PARAM_NAME_REFERER_URL)) {
|
23 |
+
$refererUrl = $url;
|
24 |
+
}
|
25 |
+
if ($url = $this->getRequest()->getParam(self::PARAM_NAME_BASE64_URL)) {
|
26 |
+
$refererUrl = Mage::helper('core')->urlDecode($url);
|
27 |
+
}
|
28 |
+
if ($url = $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED)) {
|
29 |
+
$refererUrl = Mage::helper('core')->urlDecode($url);
|
30 |
+
}
|
31 |
+
|
32 |
+
/* added fix */
|
33 |
+
//$refererUrl = Mage::helper('core')->escapeUrl($refererUrl);
|
34 |
+
|
35 |
+
if (!$this->_isUrlInternal($refererUrl)) {
|
36 |
+
$refererUrl = Mage::app()->getStore()->getBaseUrl();
|
37 |
+
}
|
38 |
+
return $refererUrl;
|
39 |
+
}
|
40 |
+
}
|
app/code/local/Hardik/Ajaxnav/controllers/Catalogsearch/ResultController.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Catalog Search controller
|
4 |
+
*
|
5 |
+
* @category Hardik
|
6 |
+
* @package Hardik_Ajaxnav
|
7 |
+
*/
|
8 |
+
require_once 'Mage/CatalogSearch/controllers/ResultController.php';
|
9 |
+
|
10 |
+
class Hardik_Ajaxnav_CatalogSearch_ResultController extends Mage_CatalogSearch_ResultController
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Display search result
|
14 |
+
*/
|
15 |
+
public function indexAction()
|
16 |
+
{
|
17 |
+
$query = Mage::helper('catalogsearch')->getQuery();
|
18 |
+
/* @var $query Mage_CatalogSearch_Model_Query */
|
19 |
+
|
20 |
+
$query->setStoreId(Mage::app()->getStore()->getId());
|
21 |
+
|
22 |
+
if ($query->getQueryText() != '') {
|
23 |
+
if (Mage::helper('catalogsearch')->isMinQueryLength()) {
|
24 |
+
$query->setId(0)
|
25 |
+
->setIsActive(1)
|
26 |
+
->setIsProcessed(1);
|
27 |
+
}
|
28 |
+
else {
|
29 |
+
if ($query->getId()) {
|
30 |
+
$query->setPopularity($query->getPopularity()+1);
|
31 |
+
}
|
32 |
+
else {
|
33 |
+
$query->setPopularity(1);
|
34 |
+
}
|
35 |
+
|
36 |
+
if ($query->getRedirect()){
|
37 |
+
$query->save();
|
38 |
+
$this->getResponse()->setRedirect($query->getRedirect());
|
39 |
+
return;
|
40 |
+
}
|
41 |
+
else {
|
42 |
+
$query->prepare();
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
Mage::helper('catalogsearch')->checkNotes();
|
47 |
+
|
48 |
+
/* custom code start */
|
49 |
+
//$isAjax = $this->getRequest()->getParam('ajax');
|
50 |
+
if ($this->getRequest()->isXmlHttpRequest()) {
|
51 |
+
$update = $this->getLayout()->getUpdate();
|
52 |
+
$update->removeHandle('catalogsearch_result_index');
|
53 |
+
$update->addHandle('catalogsearch_result_ajax_index');
|
54 |
+
|
55 |
+
// set unique cache ID to bypass caching
|
56 |
+
$cacheId = 'LAYOUT_'.Mage::app()->getStore()->getId().md5(join('__', $update->getHandles()));
|
57 |
+
$update->setCacheId($cacheId);
|
58 |
+
|
59 |
+
$this->loadLayoutUpdates();
|
60 |
+
$this->generateLayoutXml()->generateLayoutBlocks();
|
61 |
+
} else {
|
62 |
+
$this->loadLayout();
|
63 |
+
}
|
64 |
+
/* custom code end */
|
65 |
+
|
66 |
+
$this->_initLayoutMessages('catalog/session');
|
67 |
+
$this->_initLayoutMessages('checkout/session');
|
68 |
+
$this->renderLayout();
|
69 |
+
|
70 |
+
if (!Mage::helper('catalogsearch')->isMinQueryLength()) {
|
71 |
+
$query->save();
|
72 |
+
}
|
73 |
+
}
|
74 |
+
else {
|
75 |
+
$this->_redirectReferer();
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
app/code/local/Hardik/Ajaxnav/etc/config.xml
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Hardik Gajjar
|
5 |
+
*/
|
6 |
+
-->
|
7 |
+
<config>
|
8 |
+
<modules>
|
9 |
+
<Hardik_Ajaxnav>
|
10 |
+
<version>1.0.0</version>
|
11 |
+
</Hardik_Ajaxnav>
|
12 |
+
</modules>
|
13 |
+
<global>
|
14 |
+
<models>
|
15 |
+
<ajaxnav>
|
16 |
+
<class>Hardik_Ajaxnav_Model</class>
|
17 |
+
</ajaxnav>
|
18 |
+
</models>
|
19 |
+
<blocks>
|
20 |
+
<ajaxnav>
|
21 |
+
<class>Hardik_Ajaxnav_Block</class>
|
22 |
+
</ajaxnav>
|
23 |
+
</blocks>
|
24 |
+
<helpers>
|
25 |
+
<ajaxnav>
|
26 |
+
<class>Hardik_Ajaxnav_Helper</class>
|
27 |
+
</ajaxnav>
|
28 |
+
</helpers>
|
29 |
+
<rewrite>
|
30 |
+
<Hardik_ajaxnav_catalog_category>
|
31 |
+
<from><![CDATA[#^catalog/category/view/#]]></from>
|
32 |
+
<to>ajaxnav/catalog_category/view/</to>
|
33 |
+
</Hardik_ajaxnav_catalog_category>
|
34 |
+
<Hardik_ajaxnav_catalogsearch_result>
|
35 |
+
<from><![CDATA[#^/catalogsearch/result/index/#]]></from>
|
36 |
+
<to>/ajaxnav/catalogsearch_result/index/</to>
|
37 |
+
</Hardik_ajaxnav_catalogsearch_result>
|
38 |
+
<Hardik_ajaxnav_catalog_product_compare_fix>
|
39 |
+
<from><![CDATA[#^/catalog/product_compare/add/#]]></from>
|
40 |
+
<to>/ajaxnav/catalog_product_compare/add/</to>
|
41 |
+
</Hardik_ajaxnav_catalog_product_compare_fix>
|
42 |
+
</rewrite>
|
43 |
+
</global>
|
44 |
+
<frontend>
|
45 |
+
<routers>
|
46 |
+
<ajaxnav>
|
47 |
+
<use>standard</use>
|
48 |
+
<args>
|
49 |
+
<module>Hardik_Ajaxnav</module>
|
50 |
+
<frontName>ajaxnav</frontName>
|
51 |
+
</args>
|
52 |
+
</ajaxnav>
|
53 |
+
</routers>
|
54 |
+
<layout>
|
55 |
+
<updates>
|
56 |
+
<ajaxnav>
|
57 |
+
<file>ajaxnav.xml</file>
|
58 |
+
</ajaxnav>
|
59 |
+
</updates>
|
60 |
+
</layout>
|
61 |
+
</frontend>
|
62 |
+
<adminhtml>
|
63 |
+
<acl>
|
64 |
+
<resources>
|
65 |
+
<all>
|
66 |
+
<title>Allow Everything</title>
|
67 |
+
</all>
|
68 |
+
<admin>
|
69 |
+
<children>
|
70 |
+
<system>
|
71 |
+
<children>
|
72 |
+
<config>
|
73 |
+
<children>
|
74 |
+
<ajaxnav>
|
75 |
+
<title>Ajaxnav Settings</title>
|
76 |
+
</ajaxnav>
|
77 |
+
</children>
|
78 |
+
</config>
|
79 |
+
</children>
|
80 |
+
</system>
|
81 |
+
</children>
|
82 |
+
</admin>
|
83 |
+
</resources>
|
84 |
+
</acl>
|
85 |
+
</adminhtml>
|
86 |
+
</config>
|
app/design/frontend/base/default/layout/ajaxnav.xml
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<catalog_category_ajax>
|
4 |
+
<block type="page/html" name="root" output="toHtml" template="ajaxnav/ajax.phtml">
|
5 |
+
<block type="core/text_list" name="left" as="left" translate="label">
|
6 |
+
<label>Left Column</label>
|
7 |
+
</block>
|
8 |
+
<block type="core/text_list" name="content" as="content" translate="label">
|
9 |
+
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
|
10 |
+
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
|
11 |
+
<block type="page/html_pager" name="product_list_toolbar_pager"/>
|
12 |
+
<!-- The following code shows how to set your own pager increments -->
|
13 |
+
<!--
|
14 |
+
<action method="setDefaultListPerPage"><limit>4</limit></action>
|
15 |
+
<action method="setDefaultGridPerPage"><limit>9</limit></action>
|
16 |
+
<action method="addPagerLimit"><mode>list</mode><limit>2</limit></action>
|
17 |
+
<action method="addPagerLimit"><mode>list</mode><limit>4</limit></action>
|
18 |
+
<action method="addPagerLimit"><mode>list</mode><limit>6</limit></action>
|
19 |
+
<action method="addPagerLimit"><mode>list</mode><limit>8</limit></action>
|
20 |
+
<action method="addPagerLimit" translate="label"><mode>list</mode><limit>all</limit><label>All</label></action>
|
21 |
+
-->
|
22 |
+
</block>
|
23 |
+
<action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
|
24 |
+
<action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
|
25 |
+
<action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
|
26 |
+
<action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
|
27 |
+
<action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
|
28 |
+
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
|
29 |
+
</block>
|
30 |
+
</block>
|
31 |
+
</block>
|
32 |
+
</catalog_category_ajax>
|
33 |
+
|
34 |
+
<catalog_category_ajax_layered>
|
35 |
+
<reference name="left">
|
36 |
+
<block type="catalog/layer_view" name="catalog.leftnav" template="catalog/layer/view.phtml"/>
|
37 |
+
</reference>
|
38 |
+
</catalog_category_ajax_layered>
|
39 |
+
|
40 |
+
<catalog_category_ajax_default>
|
41 |
+
</catalog_category_ajax_default>
|
42 |
+
|
43 |
+
<catalog_category_default>
|
44 |
+
<reference name="head">
|
45 |
+
<action method="addJs"><script>ajaxnav/ajaxnav.js</script></action>
|
46 |
+
</reference>
|
47 |
+
</catalog_category_default>
|
48 |
+
<catalog_category_layered>
|
49 |
+
<reference name="head">
|
50 |
+
<action method="addJs"><script>ajaxnav/ajaxnav.js</script></action>
|
51 |
+
</reference>
|
52 |
+
</catalog_category_layered>
|
53 |
+
|
54 |
+
|
55 |
+
<!--search result -->
|
56 |
+
<catalogsearch_result_index>
|
57 |
+
<reference name="head">
|
58 |
+
<action method="addJs"><script>ajaxnav/ajaxnav.js</script></action>
|
59 |
+
</reference>
|
60 |
+
</catalogsearch_result_index>
|
61 |
+
<catalogsearch_result_ajax_index>
|
62 |
+
<block type="page/html" name="root" output="toHtml" template="ajaxnav/ajax.phtml">
|
63 |
+
<block type="core/text_list" name="left" as="left" translate="label">
|
64 |
+
<label>Left Column</label>
|
65 |
+
<block type="catalogsearch/layer" name="catalogsearch.leftnav" after="currency" template="catalog/layer/view.phtml"/>
|
66 |
+
</block>
|
67 |
+
<block type="core/text_list" name="content" as="content" translate="label">
|
68 |
+
<block type="catalog/product_list" name="search_result_list" template="catalog/product/list.phtml">
|
69 |
+
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
|
70 |
+
<block type="page/html_pager" name="product_list_toolbar_pager"/>
|
71 |
+
</block>
|
72 |
+
<action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
|
73 |
+
<action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
|
74 |
+
<action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
|
75 |
+
<action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
|
76 |
+
<action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
|
77 |
+
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
|
78 |
+
</block>
|
79 |
+
</block>
|
80 |
+
</block>
|
81 |
+
</catalogsearch_result_ajax_index>
|
82 |
+
</layout>
|
app/design/frontend/base/default/template/ajaxnav/ajax.phtml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
echo Zend_Json::encode(array(
|
3 |
+
'left' => $this->getChildHtml('left'),
|
4 |
+
'content' => $this->getChildHtml('content')
|
5 |
+
))
|
6 |
+
?>
|
app/etc/modules/Hardik_Ajaxnav.xml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Hardik Gajjar
|
5 |
+
*/
|
6 |
+
-->
|
7 |
+
<config>
|
8 |
+
<modules>
|
9 |
+
<Hardik_Ajaxnav>
|
10 |
+
<active>true</active>
|
11 |
+
<codePool>local</codePool>
|
12 |
+
</Hardik_Ajaxnav>
|
13 |
+
</modules>
|
14 |
+
</config>
|
js/ajaxnav/ajaxnav.js
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var ajaxnav = {
|
2 |
+
clickableObservers: false,
|
3 |
+
changeableObservers: false,
|
4 |
+
initialize: function(clickableObservers, changeableObservers) {
|
5 |
+
this.clickableObservers = clickableObservers;
|
6 |
+
this.changeableObservers = changeableObservers;
|
7 |
+
|
8 |
+
//this.setUrls();
|
9 |
+
this.bindEvents();
|
10 |
+
},
|
11 |
+
/*setUrls: function() {
|
12 |
+
var self = this;
|
13 |
+
$$(self.clickableObservers).each(function(e){
|
14 |
+
var url = e.readAttribute('href');
|
15 |
+
self.setUrl(url, e);
|
16 |
+
});
|
17 |
+
$$(self.changeableObservers + ' option').each(function(e){
|
18 |
+
var value = e.readAttribute('value');
|
19 |
+
self.setValue(value, e);
|
20 |
+
});
|
21 |
+
},
|
22 |
+
setUrl: function(url, e) {
|
23 |
+
if (url.search('ajax=true') == -1 && url.indexOf('?') == -1)
|
24 |
+
e.writeAttribute('href', url + '?ajax=true');
|
25 |
+
else if (url.search('ajax=true') == -1 && url.indexOf('?') !== -1)
|
26 |
+
e.writeAttribute('href', url + '&ajax=true');
|
27 |
+
},
|
28 |
+
setValue: function(value, e) {
|
29 |
+
if (value.search('ajax=true') == -1 && value.indexOf('?') == -1)
|
30 |
+
e.writeAttribute('value', value + '?ajax=true');
|
31 |
+
else if (value.search('ajax=true') == -1 && value.indexOf('?') !== -1)
|
32 |
+
e.writeAttribute('value', value + '&ajax=true');
|
33 |
+
},*/
|
34 |
+
bindEvents: function () {
|
35 |
+
var self = this;
|
36 |
+
$$(self.clickableObservers).each(function(e){
|
37 |
+
$(e).observe('click', function(event) {
|
38 |
+
var url = $(e).readAttribute('href');
|
39 |
+
self.ajaxcall(url);
|
40 |
+
Event.stop(event);
|
41 |
+
});
|
42 |
+
});
|
43 |
+
},
|
44 |
+
ajaxcall: function(url) {
|
45 |
+
var contentElement = $$('.category-products').first();
|
46 |
+
var appendTitle = false;
|
47 |
+
if (typeof(contentElement) == 'undefined') {
|
48 |
+
contentElement = $$('.col-main').first();
|
49 |
+
appendTitle = true;
|
50 |
+
}
|
51 |
+
var leftElement = $$('.block-layered-nav').first();
|
52 |
+
|
53 |
+
var self = this;
|
54 |
+
new Ajax.Request(url, {
|
55 |
+
onCreate : function() {
|
56 |
+
contentElement.setOpacity(0.5);
|
57 |
+
if (leftElement)
|
58 |
+
leftElement.setOpacity(0.5);
|
59 |
+
},
|
60 |
+
onSuccess : function(response) {
|
61 |
+
// Handle the response content...
|
62 |
+
try{
|
63 |
+
var res = response.responseText.evalJSON();
|
64 |
+
if (res) {
|
65 |
+
if (!appendTitle) {
|
66 |
+
$(contentElement).replace(res.content);
|
67 |
+
} else {
|
68 |
+
var title = $(contentElement).down('.category-title');
|
69 |
+
$(contentElement).innerHTML = '';
|
70 |
+
$(contentElement).insert(title);
|
71 |
+
$(contentElement).insert(res.content);
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
if (leftElement)
|
76 |
+
$(leftElement).replace(res.left);
|
77 |
+
|
78 |
+
self.initialize(self.clickableObservers, self.changeableObservers);
|
79 |
+
} else {
|
80 |
+
document.location.reload(true);
|
81 |
+
}
|
82 |
+
} catch(e) {
|
83 |
+
//window.location.href = url;
|
84 |
+
//document.location.reload(true);
|
85 |
+
}
|
86 |
+
},
|
87 |
+
onComplete : function() {
|
88 |
+
contentElement.setOpacity(1);
|
89 |
+
leftElement.setOpacity(1);
|
90 |
+
}
|
91 |
+
});
|
92 |
+
}
|
93 |
+
};
|
94 |
+
|
95 |
+
var oldSetLocation = setLocation;
|
96 |
+
var setLocation = (function() {
|
97 |
+
return function(url){
|
98 |
+
if( url.search('ajax=true') != -1 ) {
|
99 |
+
ajaxnav.ajaxcall(url);
|
100 |
+
} else {
|
101 |
+
oldSetLocation(url);
|
102 |
+
}
|
103 |
+
};
|
104 |
+
})();
|
105 |
+
|
106 |
+
document.observe("dom:loaded", function() {
|
107 |
+
ajaxnav.initialize('.block-layered-nav a, .toolbar a', '.toolbar select');
|
108 |
+
});
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>HardikAjaxNav</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Provides full ajax catalog layered navigation on product listing page as well as search results page.</summary>
|
10 |
+
<description>Provides full ajax catalog layered navigation on product listing page as well as search results page.</description>
|
11 |
+
<notes>Provides full ajax catalog layered navigation on product listing page as well as search results page.</notes>
|
12 |
+
<authors><author><name>Hardik Gajjar</name><user>hardik_krishinc</user><email>hardik.gajjar@krishinc.com</email></author></authors>
|
13 |
+
<date>2013-07-13</date>
|
14 |
+
<time>08:52:26</time>
|
15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Hardik_Ajaxnav.xml" hash="7dbe4179ff7bce21322b47eec2d1f4b9"/></dir></target><target name="magelocal"><dir name="Hardik"><dir name="Ajaxnav"><dir name="controllers"><dir name="Catalog"><file name="CategoryController.php" hash="3acce078f816f6b3561ca713d50d6335"/><dir name="Product"><file name="CompareController.php" hash="d4a9bb84eb46034cbe48a6f71cf44025"/></dir></dir><dir name="Catalogsearch"><file name="ResultController.php" hash="e35ab6ce644db4e1904589b6f5e03eda"/></dir></dir><dir name="etc"><file name="config.xml" hash="fea9c10b214493d1fe2ad52debdca577"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="ajaxnav.xml" hash="fb40a05f8dce865cfb0696e0c4fd125c"/></dir><dir name="template"><dir name="ajaxnav"><file name="ajax.phtml" hash="3dc29022a740e93be58af56b54eb01d5"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="ajaxnav"><file name="ajaxnav.js" hash="b0de1e7a1cb7bd9e37224af039fbbfb5"/></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|