E
E
Ekaterina2021-12-10 11:28:58
PHP
Ekaterina, 2021-12-10 11:28:58

How to keep the checked state without flushing the cache?

Guys, hello! Does anyone have an idea why the input's checked state only fires after the cache is flushed?

<input <?= (array_key_exists($arResult['ID'], $_SESSION["CATALOG_COMPARE_LIST"][5]["ITEMS"]) ? 'checked' : '') ?> type="checkbox" id="compareid_<?= $arResult['ID']; ?>" onchange="compare_tov(<?= $arResult['ID']; ?>);">

Answer the question

In order to leave comments, you need to log in

6 answer(s)
S
smilingcheater, 2021-12-10
@smilingcheater

Because you are using values ​​from $_SESSION, but your component's cache (is this code written in your component?) does not take into account the values ​​from the session.
And warning your next question - do not make the component cache dependent on the values ​​in the session, the whole meaning of the cache will disappear, it will only take up extra memory / space.
From simple:
- either disable the cache on the component (quick, simple and bad solution)
- or set this checked through JS, which you can add to the page in the non-cacheable part of the component (read about component_epilog.php )

E
Eugene, 2021-12-10
@udjin123

I know why, cached because, logically?
Apparently, this is related to adding products to the comparison, you call the fastest in the section or product card component, the html code is cached there, there are several ways to solve the problem

  • do not cache html, but only data (customize a component or write your own)
  • use javascript to put checked after component render
  • mark as dynamic region if compositing is enabled
  • Disable caching ;) (just kidding don't do that)

V
Viktor, 2015-06-18
@Sentim

intel and only intel. there will be fewer problems. installed and forgotten. And even it's not about performance, but about stability.
Plus, you have already been asked before: for what purposes is a PC purchased? Perhaps i3 is enough for you, but to purchase ssd + if the gaming platform, then allocate more funds for the video card. Plus, does it make sense to overpay for a K processor? will you do overclocking? maybe just a regular processor without an unlocked multiplier is enough (because there is enough performance), again it all depends on what the PC is for...

D
Denis Ineshin, 2015-06-18
@IonDen

You just want to justify buying AMD for some reason. For nothing. Take i5 and don't worry.

N
NuRsAk, 2015-06-18
@NuRsAk

I would consider Intel based solutions. For what purposes do you plan to build a PC?

V
Vladimir Zatsepin, 2015-06-18
@donneo

Well, consider the modern 1150 socket. If 1155 is still popular, then the rarer, but tempting 1156 at a price is definitely not worth it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question