<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category design
* @package base_default
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<?php
/**
* Category layered navigation
*
* @see Mage_Catalog_Block_Layer_View
*/
$current_catId=Mage::registry('current_category');
if($current_catId>0){
$max_price=Mage::getSingleton('catalog/layer')->setCurrentCategory(Mage::registry('current_category'))->getProductCollection()->getMaxPrice();
$min_price=Mage::getSingleton('catalog/layer')->setCurrentCategory(Mage::registry('current_category'))->getProductCollection()->getMinPrice();
}else{
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
$result = $db->query('SELECT max(price) as max_price ,min(price)as min_price FROM catalog_product_index_price ORDER BY customer_group_id');
$rows = $result->fetch();
$max_price= $rows['max_price'];
$min_price= $rows['min_price'];
}
?>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$(function() {
$( "#slider-range" ).slider({
range: true,
min: <?php echo $min_price;?>,
max: <?php echo $max_price;?>,
values: [ <?php echo $min_price;?>, <?php echo $max_price;?> ],
slide: function( event, ui ) {
$( "#amount" ).val( + ui.values[ 0 ] + " - " + ui.values[ 1 ] );
}
});
$( "#amount" ).val( $( "#slider-range" ).slider( "values", 0 ) +
" - " + $( "#slider-range" ).slider( "values", 1 ) );
});
function callPriceSlider()
{
var priceRang=$("#amount").val();
alert(priceRang);
var urlSpl=document.URL.split('?');
alert(urlSpl[0]+"-----"+urlSpl[1]);
var redirectUrl=urlSpl[0]+'?price='+priceRang.split(' ').join('');
alert(redirectUrl);
document.location.href=redirectUrl;
}
</script>
<?php if($this->canShowBlock()): ?>
<div class="block block-layered-nav">
<div class="block-content">
<?php echo $this->getStateHtml() ?>
<?php if ($this->getLayer()->getState()->getFilters()): ?>
<div class="actions"><a href="<?php echo $this->getClearUrl() ?>"><?php echo $this->__('Clear All') ?></a></div>
<?php endif; ?>
<?php if($this->canShowOptions()): ?>
<p class="block-subtitle"><?php echo $this->__('Categories') ?></p>
<dl id="narrow-by-list">
<?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getItemsCount()): ?>
<dt><?php echo $this->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd>
<?php endif; ?>
<?php endforeach; ?>
<dt>Price Slider:</dt>
<dd id="slider" style="height:1px"></dd>
<dd><p>
<label for="amount">Price range:</label>
<input type="text" id="amount" style="border: 0; color: #f6931f; font-weight: bold;" />
</p>
<div id="slider-range"></div>
</dd>
<dd><label onclick='callPriceSlider()' style="cursor:pointer;"> <b>Search</b> <label>
</dd>
</dl>
<script type="text/javascript">decorateDataList('narrow-by-list')</script>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category design
* @package base_default
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<?php
/**
* Category layered navigation
*
* @see Mage_Catalog_Block_Layer_View
*/
$current_catId=Mage::registry('current_category');
if($current_catId>0){
$max_price=Mage::getSingleton('catalog/layer')->setCurrentCategory(Mage::registry('current_category'))->getProductCollection()->getMaxPrice();
$min_price=Mage::getSingleton('catalog/layer')->setCurrentCategory(Mage::registry('current_category'))->getProductCollection()->getMinPrice();
}else{
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
$result = $db->query('SELECT max(price) as max_price ,min(price)as min_price FROM catalog_product_index_price ORDER BY customer_group_id');
$rows = $result->fetch();
$max_price= $rows['max_price'];
$min_price= $rows['min_price'];
}
?>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$(function() {
$( "#slider-range" ).slider({
range: true,
min: <?php echo $min_price;?>,
max: <?php echo $max_price;?>,
values: [ <?php echo $min_price;?>, <?php echo $max_price;?> ],
slide: function( event, ui ) {
$( "#amount" ).val( + ui.values[ 0 ] + " - " + ui.values[ 1 ] );
}
});
$( "#amount" ).val( $( "#slider-range" ).slider( "values", 0 ) +
" - " + $( "#slider-range" ).slider( "values", 1 ) );
});
function callPriceSlider()
{
var priceRang=$("#amount").val();
alert(priceRang);
var urlSpl=document.URL.split('?');
alert(urlSpl[0]+"-----"+urlSpl[1]);
var redirectUrl=urlSpl[0]+'?price='+priceRang.split(' ').join('');
alert(redirectUrl);
document.location.href=redirectUrl;
}
</script>
<?php if($this->canShowBlock()): ?>
<div class="block block-layered-nav">
<div class="block-content">
<?php echo $this->getStateHtml() ?>
<?php if ($this->getLayer()->getState()->getFilters()): ?>
<div class="actions"><a href="<?php echo $this->getClearUrl() ?>"><?php echo $this->__('Clear All') ?></a></div>
<?php endif; ?>
<?php if($this->canShowOptions()): ?>
<p class="block-subtitle"><?php echo $this->__('Categories') ?></p>
<dl id="narrow-by-list">
<?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getItemsCount()): ?>
<dt><?php echo $this->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd>
<?php endif; ?>
<?php endforeach; ?>
<dt>Price Slider:</dt>
<dd id="slider" style="height:1px"></dd>
<dd><p>
<label for="amount">Price range:</label>
<input type="text" id="amount" style="border: 0; color: #f6931f; font-weight: bold;" />
</p>
<div id="slider-range"></div>
</dd>
<dd><label onclick='callPriceSlider()' style="cursor:pointer;"> <b>Search</b> <label>
</dd>
</dl>
<script type="text/javascript">decorateDataList('narrow-by-list')</script>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
This can be easily achieved with that extension http://amasty.com/improved-layered-navigation.html
ReplyDeleteBut this extension is not free .. :)
Delete