سلام ، چگونه می توانم بخش فیلتر قیمت را به بخش دسته بندی ها منتقل کنم؟
از نسخه 4.20 استفاده میکنم
از نسخه 4.20 استفاده میکنم
>
function replaceUrlParam(url, paramName, paramValue) {
if (paramValue == null) {
paramValue = '';
}
var pattern = new RegExp('\\b(' + paramName + '=).*?(&|#|$)');
if (url.search(pattern) >= 0) {
return url.replace(pattern, '$1' + paramValue + '$2');
}
url = url.replace(/[?#]$/, '');
return url + (url.indexOf('?') > 0 ? '&' : '?') + paramName + '=' + paramValue;
}
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
};
var minSlider = Convert.ToInt32(Model.Products.Select(x => x.ProductPrice.PriceValue).OrderBy(p => p).FirstOrDefault());
var maxSlider = Convert.ToInt32(Model.Products.Select(x => x.ProductPrice.PriceValue).OrderByDescending(p => p).FirstOrDefault());
var breadcrumbDelimiter = commonSettings.BreadcrumbDelimiter;
if (maxSlider == 0 || minSlider == maxSlider)
{
maxSlider = 500;
}
<div class="product-filters">
<div class="product-filter product-spec-filter">
<div class="block price-block">
<div class="title"><strong>Price</strong><span class="btn-filter-collapse"></span></div>
<div class="listbox">
<div id="slider-range"></div>
<div style=" display: inline-block; width: 100%; margin: 10px 0 0; ">
<span id="js-pLeft" style="float:left;"></span>
<span id="js-pRight" style="float:right;"></span>
</div>
<button type="button" class="btn-price-reset">Reset</button>
<button type="button" class="btn-price-filter" data-min-price="@minSlider"
data-max-price="@maxSlider">Apply</button>
</div>
</div>
<script asp-location="Footer">
$(function () {
var minSlider = @minSlider;
var maxSlider = @maxSlider;
var getParam = getUrlParameter('price');
if (getParam != null) {
var valPrice = getParam.split("-");
minSlider = parseFloat(valPrice[0]);
maxSlider = parseFloat(valPrice[1]);
}
$("#js-pLeft").html(minSlider + ".00");
$("#js-pRight").html(maxSlider + ".00");
$("#slider-range").slider({
range: true,
min: minSlider,
max: maxSlider,
values: [minSlider, maxSlider],
slide: function (event, ui) {
$(".btn-price-filter").attr("data-min-price", ui.values[0]);
$(".btn-price-filter").attr("data-max-price", ui.values[1]);
$("#js-pLeft").html(ui.values[0] + ".00");
$("#js-pRight").html(ui.values[1] + ".00");
},
change: function (event, ui) {
$(".btn-price-filter").attr("data-min-price", ui.values[0]);
$(".btn-price-filter").attr("data-max-price", ui.values[1]);
$("#js-pLeft").html(ui.values[0] + ".00");
$("#js-pRight").html(ui.values[1] + ".00");
}
});
$(".btn-price-filter").on("click", function () {
var minPrice = $(".btn-price-filter").attr("data-min-price");
var maxPrice = $(".btn-price-filter").attr("data-max-price");
var geturl = replaceUrlParam(window.location.href, "price", minPrice + "-" + maxPrice);
setLocation(geturl);
});
$(".btn-price-reset").on("click", function () {
var geturl = replaceUrlParam(window.location.href, "price");
setLocation(geturl.replace("price=", ""));
});
});
var range = _webHelper.QueryString<string>("price");
if (!string.IsNullOrEmpty(range))
{
var fromTo = range.Trim().Split(new[] { '-' });
if (fromTo.Length == 2)
{
if (!string.IsNullOrEmpty(fromTo[0]) && !string.IsNullOrEmpty(fromTo[0].Trim()))
minPriceConverted = decimal.Parse(fromTo[0].Trim(), new CultureInfo("en-US"));
if (!string.IsNullOrEmpty(fromTo[1]) && !string.IsNullOrEmpty(fromTo[1].Trim()))
maxPriceConverted = decimal.Parse(fromTo[1].Trim(), new CultureInfo("en-US"));
}
}