aw filter layer navigation onclick event

Please find out the below direct link for aw layer navigation

http://ecommerce.aheadworks.com/magento-extensions/layered-navigation.html

In this all the category and subcatogary working on ajax request or page realod. how to stop layer navigation on ajax request and do this in onclick event with multiselection attribute likeĀ  multiple size , color , manufacture .

Please follow the below steps for to avoid ajax request and add all filter in buttons click events

please add or replace below code in layer.phtml file located in (app/design/frontend/ your themes /template/aw_layerednavigation/layer.phtml)

 

<?php /** @var AW_Layerednavigation_Block_Layer $this */ ?>
<?php if($this->canShowBlock()): ?>
    <div class="block block-layered-nav" id="aw-ln-filters">
        <div class="block-title">
            <strong><span><?php echo $this->__('Shop By') ?></span></strong>
        </div>
        <div class="block-content">
            <script type="text/javascript">
                var awLnUpdaterInstance = new awLnUpdater();
            </script>
            <?php if($this->isLayerHasAppliedValue()): ?>
                <span class="aw-ln-clear-all">
                    (<a href="javascript:void(0)"><?php echo $this->__("Clear All");?></a>)
                </span>
            <?php endif;?>
            <p class="block-subtitle">
                <?php echo $this->__('Shopping Options') ?>
            </p>
            <div style="clear:both"></div>
            <dl id="aw-ln-filters-container">
                <?php foreach ($this->getFilterList() as $_filter): ?>
                    <?php if($this->getItemCountByFilter($_filter)): ?>
                        <dt>
                            <span><?php echo $_filter->getTitle() ?></span>
                            <?php if ($this->isFilterHasAppliedValues($_filter)):?>
                                <span class="aw-ln-filter-clear">
                                    (<a href="javascript:void(0)"><?php echo $this->__("Clear");?></a>)
                                </span>
                            <?php endif;?>
                        </dt>
                        <dd>
                            <?php echo $this->renderFilter($_filter) ?>
                        </dd>
                    <?php endif; ?>
                <?php endforeach; ?>
                <form id="frmfilter" action="<?php echo Mage::registry('current_category')->getUrl(); ?>" method="GET">
                    <input type="hidden" name="category" id="category" value=""/>
                    <input type="hidden" name="color" id="color" value=""/>
                    <input type="hidden" name="format" id="format" value=""/>
                    <input type="hidden" name="manufacturer" value="" id="manufacturer"/>
                    <input type="hidden" name="size" id="size" value="" />
                </form>
                <input type="button" value="Filter" name="Filter" id="btnfilter" disabled="disabled"/>
            </dl>
            <script type="text/javascript">
                jQuery(document).ready(function($){
                   $("#aw-ln-filters-container input").on("click",function(){
                        trigger_cat();
                        /* if($(this).is(':checked')){
                            var add = $(this).val();
                            var listOfNumbers = $("#"+$(this).attr("name")).val();
                            if(listOfNumbers !=""){
                                var temp = listOfNumbers+','+add;
                                $("#"+$(this).attr("name")).val(temp);
                            }else {
                                $("#"+$(this).attr("name")).val(add);
                            }
                            $("#btnfilter").removeAttr("disabled");
                        }*/
                   });
                   $("#btnfilter").on("click",function(){
                        var url = "";
                        if($("#category").val() !=""){
                          url +="&category="+$("#category").val();
                        }
                        if($("#color").val() !=""){
                          url +="&color="+$("#color").val();
                        }
                        if($("#format").val() !=""){
                          url +="&format="+$("#format").val();
                        }
                        if($("#manufacturer").val() !=""){
                          url +="&manufacturer="+$("#manufacturer").val();
                        }
                        if($("#size").val() !=""){
                          url +="&size="+$("#size").val();
                        }
                        window.location.href='<?php echo Mage::registry('current_category')->getUrl(); ?>?'+url.substring(1);
                   });
                });
                function trigger_cat(){
                     jQuery("#category").val('');
                     jQuery("#color").val('');
                     jQuery("#format").val('');
                     jQuery("#manufacturer").val('');
                     jQuery("#size").val('');
                     var btn = false;
                     jQuery("#aw-ln-filters-container input").each(function(){
                        if(jQuery(this).is(':checked')){
                            btn = true;
                            var temp = "";
                            var add = jQuery(this).val();
                            var listOfNumbers = jQuery("#"+jQuery(this).attr("name")).val();
                            if(listOfNumbers !="" && add !=""){
                                var temp = listOfNumbers+','+ add;
                                var array1 = jQuery.unique(temp.split(","));
                                jQuery("#"+jQuery(this).attr("name")).val(array1.join());
                            }else {
                                jQuery("#"+jQuery(this).attr("name")).val(add);
                            }
                        }
                     });
                     if(btn){
                        jQuery("#btnfilter").removeAttr("disabled");
                     }
                }
                decorateDataList('aw-ln-filters');
                awLnUpdaterInstance.init({
                    layerContainerElSelector: ".block-layered-nav",
                    productsContainerElSelectorList: [".category-view", ".results-view", ".category-products"],
                    emptyProductsContainerElSelectorList: [".note-msg"],
                    toolbarContainerElSelectorList: [
                        ".category-view .toolbar",
                        ".results-view .toolbar",
                        ".category-products .toolbar"
                    ],
                    clearAllElSelector: '.aw-ln-clear-all',
                    clearFilterElSelector: '.aw-ln-filter-clear',
                    isAjax: <?php echo Zend_Json::encode($this->isAjax());?>,
                    overlaySettings: <?php echo Zend_Json::encode($this->getOverlaySettings());?>,
                    overlayCssClass: 'aw-ln-overlay'
                });
            </script>
        </div>
    </div>
<?php endif; ?>

 

Related posts