1. 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

Discussion in 'Styling and Customization Questions' started by Cats777, Feb 21, 2012.

  1. Cats777

    Cats777 Member

    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.
  2. Jake Bunce

    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.
  3. Cats777

    Cats777 Member

    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.
    Mike Creuzer likes this.
  4. Jake Bunce

    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.
  5. Cats777

    Cats777 Member

    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.
  6. Mike Creuzer

    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.

Share This Page