Answer the question
In order to leave comments, you need to log in
How to modify smart filter?
I would like to show round numbers in the smart filter in the slider (0, 100, 200, 300, 400).
Bitrix takes them from the database. There are different numbers.
Accordingly, they are calculated in the slider themselves.
In the template, I found where you can change these numbers:
$value1 = number_format($arItem["VALUES"]["MIN"]["VALUE"], $precision, ".", "");
$value2 = number_format($arItem["VALUES"]["MIN"]["VALUE"] + $step, $precision, ".", "");
$value3 = number_format($arItem["VALUES"]["MIN"]["VALUE"] + $step * 2, $precision, ".", "");
$value4 = number_format($arItem["VALUES"]["MIN"]["VALUE"] + $step * 3, $precision, ".", "");
$value5 = number_format($arItem["VALUES"]["MAX"]["VALUE"], $precision, ".", "");
Answer the question
In order to leave comments, you need to log in
Here I read, it seems that the question is normal and you are moving in the right direction, and you understand that you need to edit script.js. And in the end, advise how to fix javascript without editing javascript. Yes, no way!
Do you have a javascript phobia? )
1. Open template.php, look for where new BX.Iblock.SmartFilter is called there, parameters above this call
$arJsParams = array(
"leftSlider" => 'left_slider_'.$key,
// .............
// добавляешь свой параметр, например step (значение = шаг)
"step" => 100
);
var SmartFilter = function(arParams)
{
if (typeof arParams === 'object')
{
this.leftSlider = BX(arParams.leftSlider);
// ...........
// где-нибудь здесь добавляешь
this.step = arParams.step || 1;
}
};
SmartFilter.prototype.recountMinPrice = function()
{
var newMinPrice = (this.priceDiff*this.leftPercent)/100;
newMinPrice = (this.minPrice + newMinPrice).toFixed(this.precision);
// добавляешь эту строку
newMinPrice = Math.round(newMinPrice/this.step) * this.step;
if (newMinPrice != this.minPrice)
this.minInput.value = newMinPrice;
else
this.minInput.value = "";
/** @global JCSmartFilter smartFilter */
smartFilter.keyup(this.minInput);
};
SmartFilter.prototype.recountMaxPrice = function()
{
var newMaxPrice = (this.priceDiff*this.rightPercent)/100;
newMaxPrice = (this.maxPrice - newMaxPrice).toFixed(this.precision);
// добавляешь эту строку
newMaxPrice = Math.round(newMaxPrice/this.step) * this.step;
if (newMaxPrice != this.maxPrice)
this.maxInput.value = newMaxPrice;
else
this.maxInput.value = "";
/** @global JCSmartFilter smartFilter */
smartFilter.keyup(this.maxInput);
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question