Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

Color-picker?


Reply


39 Posts   8165 Views

Avatar
banal

Community Member, 901 Posts

20 December 2009 at 2:20am

It all depends what you want to do with it. As I said: This module is just a color selector field in the CMS. What you do with the color is entirely up to you. As an example you could add something like this to your Page.ss template:

<style type="text/css">
body { background:#$BgColor; }
</style>

This would then apply your selected color as Page Background...

Avatar
UncleCheese

Forum Moderator, 4092 Posts

20 December 2009 at 2:33am

Hi, Roman,

Just a thought... Maybe your color picker module could come with its own field type, e.g.

static $db = array (
'MyColor' => 'Color'
);

$MyColor.RGB $MyColor.Hex.. etc..

function scaffoldFormField() { return new ColorPicker(... etc); }

Avatar
Mikan

Community Member, 17 Posts

20 December 2009 at 2:34am

oh,

unfortunately,

How to use the "background Color" to Content of each page that I created?

Is there a way to add color to my Contents?

Thanks

Avatar
banal

Community Member, 901 Posts

20 December 2009 at 2:40am

@UncleCheese: Yeah, the own field-type for colors might be a good idea. I'll probably integrate this for a SS 2.4 release.

@Mikan: I gave you enough information to change the background color for each of your pages... you should go through the tutorials and get familiar with SilverStripe. People won't write all the code for you here.

Avatar
UncleCheese

Forum Moderator, 4092 Posts

20 December 2009 at 2:40am

I think this is what you want?

<div style="background:#$BackgroundColor">$Content</div>

You're a braver man than I. I don't think I would ever empower my clients to have control over background colors. Yikes.

Avatar
banal

Community Member, 901 Posts

20 December 2009 at 2:49am

@UncleCheese It depends on who your client is really. I used this for my own website, and also for websites of graphic-designers. But it's not something i'd recommend to everybody :)

@Mikan Since the field name is BgColor, you should use that in the template ($BgColor). I already wrote how to change the background color some posts before, even before you asked. Don't know what else you need to know..

Avatar
pinkp

Community Member, 168 Posts

3 February 2010 at 11:05am

This is a brilliant addition! Exactly what I needed, many thanks Banal

Avatar
go2planC

Community Member, 19 Posts

14 April 2010 at 11:23am

Firstly this is amazing. Gave me exactly what I was looking. Must admit I was sweating when I told my client I could do this - then found your colour picker code! Worked a treat. Well until I ran into a problem with it not displaying within a CMS Pop-up. This is actually quite confusing as i have it working fine on my local machine running XAMPP but now that it is on a live hosting server it isn't. It's just displaying the text field. I have it working elsewhere in the CMS just not in a pop-up though.

Any ideas as I'm stumped?!