XF 2.1 Having issue with detecting options in templates

Matt C.

Well-known member
I'm having issues with detecting options in templates. I think this actually might be a bug, but I wanted to ask here before reporting it.

I'm using the following code:
Code:
<xf:if is="$xf.options.ahfaAM">

</xf:if>

I know the code works because I have the option checked, the css under it if statement renders on the front end. If I uncheck it, it still shows. But I remove the code, and re add it, then it doesn't render and vice versa. I have a video to demonstrate this.

(Please excuse the audio in the background, I had a movie playing)
View attachment XenForo - Google Chrome 12_14_2018 5_58_41 AM.mp4

















Thank you!
 
The problem with this is that the LESS code isn't parsed on-the-fly in the front-end. I'm speculating a bit here, but it is my understanding that styles have a "last update" date which is compared to the cached "last cached" date. If the last update is newer than the last cached date, all LESS files are compiled (all <xf> tags are parsed and resolved) and cached as raw CSS where no <xf> tags will work.

In order to fix this, edit your ahfaAM option and use this as the verification callback: XF\Option\Style :: triggerStyleUpdate

Then, toggle your option back and forth, and you should (hopefully) see your option be reflected in what CSS is loaded :)


Fillip
 
The problem with this is that the LESS code isn't parsed on-the-fly in the front-end. I'm speculating a bit here, but it is my understanding that styles have a "last update" date which is compared to the cached "last cached" date. If the last update is newer than the last cached date, all LESS files are compiled (all <xf> tags are parsed and resolved) and cached as raw CSS where no <xf> tags will work.

In order to fix this, edit your ahfaAM option and use this as the verification callback: XF\Option\Style :: triggerStyleUpdate

Then, toggle your option back and forth, and you should (hopefully) see your option be reflected in what CSS is loaded :)


Fillip
Thanks !

Does it concern only this type of option?

Screenshot_7.png

Or several types ?
Screenshot_8.png
 
It's completely unrelated to the type. If you want to make options that you're going to use in a less file, they should be style properties instead.
 
Back
Top Bottom