Choosing color css themes via cmsB
2 posts by 2 authors in: Forums > CMS Builder
Last Post: September 18, 2014 (RSS)
By JeffC - September 18, 2014
I wanted to give my client the ability to choose some colors for their site, and here’s what I did so far (example changes the background color of a page)…
1. Created a multi record editor (I called it “Color Choices”) with only 2 text fields: Color (ie White) and HEX Color (ie FFFFFF). I created a record for each color I wanted to allow.
2. I then created a single record editor called “clients choices” and in that create a list field called “Page Background” that gets its options from the database “Color Choices” with the option values from the “hex_color” field and the option labels from the “color_choices” field
3. Lastly, in my css.php file I inserted: body {background-color: #<?php echo $client_choicesRecord[‘page_background'] ?>;}
4. The concept can be used to change the colour of any css element.
The above solution works. However, now I’m thinking that my solution gives the client the option to make too many BAD choices (ie combinations of color that look horrible together), and I want to set up the system to where they can only choose a theme and it will automatically populate the appropriate fields.
For example a theme called 'red' might include a white background, black text and variations of red for link colour, highlighted link etc... So my basic css would look like this:
body {background-color: #FFFFFF;}
font {color:#000000;}
a {color: #FF0000;}
a:hover {color: #700000;}
Could any one help me develop my current solution to achieve my new objective. How would I set up the fields in cmsB and what would my css.php file look like?
Thanks
By claire - September 18, 2014
Hey there
The best way to do this would be to modify the Color Choices section.
Change it to something like Theme Choices, and include the fields: Name, CSS - name is the name of the theme, and CSS is a text field that includes the list of styles for the theme.
In the single record Clients Choices, cut the list down to Themes only, which consists of a list pointing to Theme Choices.
Then all you have to do is insert the CSS text block at the end of your css.php to override all other styles.
This would let you set as many styles as you need for a theme, and prevent the client from making any really bad choices.
Claire Ryan
interactivetools.com
Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/