D
D
Darklt2021-12-08 00:19:52
1C-Bitrix
Darklt, 2021-12-08 00:19:52

How to update the buffer in Bitrix?

Wrote a script for adding a product to the product list. They are marked with classes. Everything is well preserved, but if you use the browser buttons to go to another page and then return, the classes do not appear. I add a class from an array:

$idUser = $USER->GetID();
    $rsUser = CUser::GetByID($idUser);
    $arUser = $rsUser->Fetch();
    $arFavorites = $arUser['UF_FAVORITES'];


then I check if there is a value in the array that was added

<?if (in_array($arResult['ID'], $arFavorites)) {
    echo "active";
}?>

and add the active class there, at the click stage, the active class is simply added using standard JS

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Zhitnik, 2021-12-08
@art-zhitnik

If $arFavorites is obtained in the component's template code or in result_modifier.php, component caching may be triggered. Better then do these manipulations in component_epilog.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question