Answer the question
In order to leave comments, you need to log in
Is it possible to use $APPLICATION->ShowProperty() in component template code?
If everything is clear with the SetPageProperty, SetTitle, etc. functions, they simply will not be executed when the cache is enabled. I don’t fully understand with $APPLICATION->ShowProperty(), it seems like it should put a label that will be filled later with actual data and, therefore, the label should be cached and later filled in.
Now I need to recolor the menu in the header depending on the section. I set in the index.php of the section
$APPLICATION->SetPageProperty('category_style', 'is-red');
class="top-menu <?$APPLICATION->ShowProperty('category_style', '');?>"
Answer the question
In order to leave comments, you need to log in
There is such a task in exam No. 2 ex2-109 "Change the background in the header"
I already answered a similar question How to display the section property in Bitrix?
Yaroslav Alexandrov , Evgeny Thank you, the answer is clear. Just sometimes I really want to)
If this call cached a string that was later parsed before output, and its value was changed just before the output (as I thought), I would get the necessary effect. But as I see these ShowProperty(), ShowTitle() functions work differently (they close the current buffer, create another one to display the result of the function, then close it and open a new one) in general, not at all as I thought. Therefore, when the component is cached, this does not happen at all, but the effect is that only part of the component's output is cached after calling ShowProperty ().
Conclusions
1) ShowProperty(), ShowTitle() cannot be used in cached parts of the code.
2) Either we transfer their use to the site template, or to non-cached pages of complex components (such as detail.php section.php news.php, etc.)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question