Set Color Palette Using Code

Is it possible to set the colors of the palette with a bit of code? I could store it in a variable (e.g. var h = "@primaryLight"), but I can't figure out how to do it the other way around. I would like to dynamically set the tone of the forums under certain conditions.

Jake Bunce

XenForo moderator
Staff member
I have never tried that before.

What are the conditions? And what colors do you want to change? You can get away with a lot using template conditionals.
I want to make my board have a day/night cycle. I already wrote the code to check the server time and change the background image if necessary, but I'd like to go all out and change the board's color palette as well.

Jake Bunce

XenForo moderator
Staff member
Here are time-based conditionals that can be used in the HTML templates (not the CSS templates):

Within the HTML you can conditionally display inline styling or class names, where the classes are later defined in the CSS. For example, if you want to change the body background then you can edit PAGE_CONTAINER and conditionally include inline styling in the <body> tag.
Actually, being unfamiliar with Xen tags, I wrote the background changer in JavaScript. I don't know which is more efficient, but it works. What I want to do now is figure out how to directly change the color palette, because writing something to change the colors of each div on the board would be a hassle.

Mike Creuzer

Well-known member
Just so you know, I tried figuring out a way to do this and asked around as well, and was sadly unable to figure out a way.

What I was able to do was use two different skins (thus two different color palettes), and what you could do is add a link to change the style somewhere in the header, there might even be a way to change the skin based on the time.