XF 2.0 CSS (LESS) and xf.options

Snog

Well-known member
I think I'm losing my mind. I'm pretty sure I've done this in XF1 without a problem. ;)

I have this in a .less template...
Code:
width: {$xf.options.snog_member_card_size}px;

Which works fine initially. However, when the value is updated in Options, it doesn't change in the CSS (less).

Any ideas?
 
Might need to invest in a class extension that checks if that option changed and rebuilds the style information. I'd look into how the LESS files are built when you edit them and apply that to the class extension.


Fillip
 
It's probably because updating the option won't trigger the LESS to recompile, something like this would probably make more sense as a style property though, wouldn't it?

Edit: Oh, guess I got double-ninjaed
 
Last edited:
Yeah, a style property would probably be better.

I was trying to keep everything in one place. But a style property would work.
 
Style properties could well be more appropriate in this case, though there are use cases for using options in Less templates. For example, XFMG has an option to control the actual dimensions the thumbnails are created at (and it is used for the display sizing of the thumbnails in CSS) - this makes no sense as a style property as there is only one thumbnail and it needs to be the same size regardless of what style you're using.

In that case, we have a Validation callback populated on that option with:
Code:
XF\Option\Style :: triggerStyleUpdate
That's enough to invalidate the CSS cache when the option is updated.
 
@Chris D Thank you!

That's exactly what I was looking for. It saves me from having to create a style property for one or two items. :)
 
Back
Top Bottom