• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Set Color Palette Using Code

#1
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
#2
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.
 
#3
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
#4
Here are time-based conditionals that can be used in the HTML templates (not the CSS templates):

http://xenforo.com/community/threads/time-based-board-header.15298/

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.
 
#5
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
#6
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.