XF 2.0 How use user custom field in .less template?

CMTV

Well-known member
Hi!

I have a custom user field called test_color.

How can I use the value of this field in extra.less or other less templates?

Is there a way to do so without involving xenForo development mode and writing addons?
 
you can't really set things per user in css templates because they get cached by the browser and CDN if you use CloudFlare. You'd be better off putting it inline in PAGE_CONTAINER or something similar
 
You'd be better off putting it inline in PAGE_CONTAINER or something similar
I don't really understand what you mean... Can you provide a very simple example?

Do you mean I have to write something like this?
HTML:
<xf:if is="{$xf.visitor.Profile.custom_fields.test_color}">
    <xf:css src="custom.less"/>
</xf:if>

But it would be great to somehow pass test_color value to custom.less.
 
You won't be able to use a custom user field within a less template, they get cached by the browser so there will be a lot of unexpected things happening. You'll just need to include the extra less template with a conditional like you used above
 
Top Bottom