Answer the question
In order to leave comments, you need to log in
Smart filter, replace "From", "To" values with minimum and maximum values?
Good afternoon! I met with a problem, I want to put these values in the smart filter in the input fields of the maximum and minimum values, those with a slider, by default in these fields there are simply the inscriptions "From" and "To".
Of course, you can put it in placeholder="<?=$arItem["VALUES"]["MIN"]["VALUE"]?>" but this is again not very beautiful, because there are actually no values in the fields.
/bitrix/www/bitrix/components/bitrix/catalog.smart.filter/templates/bootstrap_v4/template.php ~80 line
<div class="smart-filter-input-container">
<input
class="min-price form-control form-control-sm"
type="number"
name="<? echo $arItem["VALUES"]["MIN"]["CONTROL_NAME"] ?>"
id="<? echo $arItem["VALUES"]["MIN"]["CONTROL_ID"] ?>"
value="<? echo $arItem["VALUES"]["MIN"]["HTML_VALUE"] ?>"
size="5"
placeholder="<?=$arItem["VALUES"]["MIN"]["VALUE"]?>"
onkeyup="smartFilter.keyup(this)"
/>
</div>
<?=($arItem["VALUES"]["MIN"]["HTML_VALUE"]) ? round($arItem["VALUES"]["MIN"]["HTML_VALUE"]) : ($arItem["VALUES"]["MIN"]["VALUE"])?>
Answer the question
In order to leave comments, you need to log in
Hello again)
In the template of the filter component in template.php in value you did the right thing, just remove the round and add the corresponding data parameters to the inputs
data-price="<?=$arItem["VALUES"]["MIN"]["VALUE"];?>"
data-price="<?=$arItem["VALUES"]["MAX"]["VALUE"];?>"
JCSmartFilter.prototype.setInputsPrice = function() {
if(!this.form)
return;
if(!Object.keys(this.inputsPrice).length) {
var inputs = BX.findChildren(this.form, {'tag': new RegExp('^(input)$', 'i'), 'attribute': {'data-price': new RegExp('^(.*)$', 'i')}}, true);
inputs.forEach(function(item, i) {
this.inputsPrice[item.name] = item.dataset.price;
}, this);
}
}
JCSmartFilter.prototype.values = function(values) {
values.forEach(function(item, i) {
if(Object.keys(this.inputsPrice).indexOf(item.name) !== -1) {
values[i].value = parseFloat(item.value) !== parseFloat(this.inputsPrice[item.name]) ? item.value : '';
}
}, this);
}
if (newMinPrice != this.minPrice)
this.minInput.value = newMinPrice;
else
this.minInput.value = "";
Make the AJAX mode only for the catalog.smart.filter Bitrix filter. Override make FORM_ACTION your own
<script>
var smartFilter = new JCSmartFilter('<?=CUtil::JSEscape($arResult['FORM_ACTION'])?>/ajax/catalog_smart_filter_ajax.php');
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question