Request: Set/Change Colors from Admin Page
Posted by Joe Curia
|
Request: Set/Change Colors from Admin Page February 04, 2007 06:03AM |
Registered: 19 years ago Posts: 1,301 |
I'm not sure where to post this request, but as it deals with templates first and foremost, I thought I would put it here.
First off, please understand that in my opinion, and with no offence intended to the other templates uploaded here, I do not believe that simply changing colors should qualify as a new template. I think that color changes should be made easier and template independent. A template should change layout and design, not simply the color scheme of the site.
So, if you accept my basic tenet, here is my suggestion. Code in color constants which are then used throughout the templates. I know this is already in place, but the templates look to the settings.tpl file for their colors. The colors would then be configurable from the admin section, say a "site colors" section in the general settings page, or even a page of their own. I'm not much of a coder but would be willing to help create that page if you decide to implement this feature.
Here is how it would work (in my preliminary opinion):
Set these color variables in the admin settings:
{! --- common body-colors --- }
bodybackground, defaulttextcolor, backcolor, newflagcolor, errorfontcolor, okmsgfontcolor
{! --- for the forum-list ... alternating colors --- }
altbackcolor, altlisttextcolor
{! --- common link-settings --- }
linkcolor, activelinkcolor, visitedlinkcolor, hoverlinkcolor
{! --- for the Navigation --- }
navbackcolor, navtextcolor, navhoverbackcolor, navhoverlinkcolor
{! --- for the PhorumHead ... the list-header --- }
headerbackcolor, headertextcolor
tablebordercolor, listlinecolor, listpagelinkcolor, listmodlinkcolor
If possible (and I will try to find code for this), the colors selection fields should either give a preview of the color value entered or actually allow you to select from a color display.
Once set, ask that all templates created use these same color names throughout their template. Be sure that the color names look to the database and not a static file. Now any admin can quickly and easily recolor their site.
I am not a SQL/Web guru, so I don't know what the impact on performance would be, but it seems that we are already loading the color settings from a different page and that every page calls the db anyways, so hopefully the impact would not be too terrible.
Any thoughts/improvements on this idea are welcome. As stated above, if the Phorum developers decide to go with this I would love to offer my help wherever possible, just let me know what I can do.
First off, please understand that in my opinion, and with no offence intended to the other templates uploaded here, I do not believe that simply changing colors should qualify as a new template. I think that color changes should be made easier and template independent. A template should change layout and design, not simply the color scheme of the site.
So, if you accept my basic tenet, here is my suggestion. Code in color constants which are then used throughout the templates. I know this is already in place, but the templates look to the settings.tpl file for their colors. The colors would then be configurable from the admin section, say a "site colors" section in the general settings page, or even a page of their own. I'm not much of a coder but would be willing to help create that page if you decide to implement this feature.
Here is how it would work (in my preliminary opinion):
Set these color variables in the admin settings:
{! --- common body-colors --- }
bodybackground, defaulttextcolor, backcolor, newflagcolor, errorfontcolor, okmsgfontcolor
{! --- for the forum-list ... alternating colors --- }
altbackcolor, altlisttextcolor
{! --- common link-settings --- }
linkcolor, activelinkcolor, visitedlinkcolor, hoverlinkcolor
{! --- for the Navigation --- }
navbackcolor, navtextcolor, navhoverbackcolor, navhoverlinkcolor
{! --- for the PhorumHead ... the list-header --- }
headerbackcolor, headertextcolor
tablebordercolor, listlinecolor, listpagelinkcolor, listmodlinkcolor
If possible (and I will try to find code for this), the colors selection fields should either give a preview of the color value entered or actually allow you to select from a color display.
Once set, ask that all templates created use these same color names throughout their template. Be sure that the color names look to the database and not a static file. Now any admin can quickly and easily recolor their site.
I am not a SQL/Web guru, so I don't know what the impact on performance would be, but it seems that we are already loading the color settings from a different page and that every page calls the db anyways, so hopefully the impact would not be too terrible.
Any thoughts/improvements on this idea are welcome. As stated above, if the Phorum developers decide to go with this I would love to offer my help wherever possible, just let me know what I can do.
|
Re: Request: Set/Change Colors from Admin Page February 04, 2007 06:49AM |
Admin Registered: 22 years ago Posts: 8,532 |
Phorum 3 had the color settings in the admin, but that was moved to the templates themselves in Phorum 5 for good reasons. I don't see the colors coming back as a feature in the admin.
I do agree that it would be nice for beginning admins to be able to set the colors from a configuration interface. For some time I've been thinking about releasing a template with an additional module. The module would be used for configuring template settings, so the admin doesn't need to touch settings.tpl. Admins who want some extra performance could ignore the module and go for changing settings.tpl right away.
This would not be a general solution for all templates. That seems to be what you are aiming at. The problem that I have with a general solution is that it restricts template builders in what they can do in the templates. Changing layout and design (you got it right that that is what templates are for) can easily involve using more colors and even background images instead of colors. By dictating the color rules to a template, building templates becomes less free. I also think that even if the rules were dictated, people would still design and release their own templates, not conforming to the color rules. That would generate questions about problems with the color settings.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
I do agree that it would be nice for beginning admins to be able to set the colors from a configuration interface. For some time I've been thinking about releasing a template with an additional module. The module would be used for configuring template settings, so the admin doesn't need to touch settings.tpl. Admins who want some extra performance could ignore the module and go for changing settings.tpl right away.
This would not be a general solution for all templates. That seems to be what you are aiming at. The problem that I have with a general solution is that it restricts template builders in what they can do in the templates. Changing layout and design (you got it right that that is what templates are for) can easily involve using more colors and even background images instead of colors. By dictating the color rules to a template, building templates becomes less free. I also think that even if the rules were dictated, people would still design and release their own templates, not conforming to the color rules. That would generate questions about problems with the color settings.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
|
Re: Request: Set/Change Colors from Admin Page February 04, 2007 07:19AM |
Registered: 19 years ago Posts: 1,301 |
|
Re: Request: Set/Change Colors from Admin Page February 04, 2007 12:11PM |
Admin Registered: 22 years ago Posts: 8,532 |
Quote
I think I will work to develop the color setting mod if I can learn enough of the php/sql/javascript needed to do it.
That sounds great! One idea I had this afternoon was that some dynamic detection could be used for implementing this kind of mod. The mod could try to fish all color definitions from the template settings and work with those. It's easy to override the definitions from the settings.tpl from a module.
The tricky part is to show a dynamic preview. I have some ideas for that, but it involves quite a bit of hackery.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
|
Re: Request: Set/Change Colors from Admin Page February 04, 2007 07:16PM |
Registered: 19 years ago Posts: 1,301 |
I don't know if this thread should be moved elsewhere now, but I have started the mod creation and have a couple of questions.
I have two options for the settings.tpl. I am able to import the color settings from the current template (provided they use the same variable names as the default template) and I can easily rewrite the file with new colors or put the colors in the database. Obviously storing the colors in the database is safer and less invasive to the template.
My first question is how to bypass the colors of the settings.tpl with settings stored in the database? After looking through the process of building the urls (ie index.php, common.php, etc.) it seems to me that if I define the "PHORUM_SCRIPT" variable then common.php will not load the settings.tpl file (see lines 319+) and I can then set those variables myself in the common hook. However, I don't know if this is the best way to go about it. Here my lack of programming will show through, but can I simply include my own settings.tpl which will overwrite the variables already imported?
My second question is which method (settings from db or settings from altered settings.tpl) is faster, more secure, etc.
I hope my questions make sense and you can help me with them. Thanks in advance.
I have two options for the settings.tpl. I am able to import the color settings from the current template (provided they use the same variable names as the default template) and I can easily rewrite the file with new colors or put the colors in the database. Obviously storing the colors in the database is safer and less invasive to the template.
My first question is how to bypass the colors of the settings.tpl with settings stored in the database? After looking through the process of building the urls (ie index.php, common.php, etc.) it seems to me that if I define the "PHORUM_SCRIPT" variable then common.php will not load the settings.tpl file (see lines 319+) and I can then set those variables myself in the common hook. However, I don't know if this is the best way to go about it. Here my lack of programming will show through, but can I simply include my own settings.tpl which will overwrite the variables already imported?
My second question is which method (settings from db or settings from altered settings.tpl) is faster, more secure, etc.
I hope my questions make sense and you can help me with them. Thanks in advance.
|
Re: Request: Set/Change Colors from Admin Page February 05, 2007 12:47AM |
Admin Registered: 25 years ago Posts: 4,506 |
Quote
Azumandias
My first question is how to bypass the colors of the settings.tpl with settings stored in the database?
What you will want to do is make a common hook module that overrides the entries in the $PHORUM["DATA"] array. var elements in settings.tpl (or any template for that matter) are transfered into the $PHORUM["DATA"] array. For example:
{var bodybackground White}
becomes
$PHORUM["DATA"]["bodybackground"] = 'White';So, your module would just need to override those values in the global scope.
Brian - Personal Blog
|
Re: Request: Set/Change Colors from Admin Page February 05, 2007 06:21AM |
Registered: 19 years ago Posts: 1,301 |
function phorum_mod_easy_colorscheme_common () {
$PHORUM = $GLOBALS["PHORUM"];
echo "<script>alert('".$PHORUM["DATA"]["bodybackground"]."');</script>";
$PHORUM["DATA"]["bodybackground"] = "#CCCCCC";
echo "<script>alert('".$PHORUM["DATA"]["bodybackground"]."');</script>";
return;
}
function phorum_mod_easy_colorscheme_after_header () {
$PHORUM = $GLOBALS["PHORUM"];
echo "<script>alert('".$PHORUM["DATA"]["bodybackground"]."');</script>";
return;
}
What I am seeing when the page loads is the first alert showing #FFFFFF (from the settings.tpl), the second showing #CCCCCC, and the third showing #FFFFFF. Somewhere between the common hook and the after_header hook my variable overwrite is being overwritten again and the background on the page is white, not grey. Any ideas would be appreciated.
EDIT Nevermind, after typing up here and mulling it over during the day I realized that I was only changing a variable local to the function and not the global variable. I made this change and it works fine:
$PHORUM["DATA"]["bodybackground"] = "#CCCCCC"; changed to: $GLOBALS["PHORUM"]["DATA"]["bodybackground"] = "#CCCCCC";
Edited 3 time(s). Last edit at 02/05/2007 01:48PM by Azumandias.
|
Re: Request: Set/Change Colors from Admin Page February 06, 2007 11:19AM |
Registered: 19 years ago Posts: 1,301 |
Well, I have finished the first version of my Easy Color Scheme Manager and uploaded it to the module forum: [www.phorum.org]
I was able to pull the standard variables from the settings.tpl as you suggested and create a preview feature (though it only shows the first page in the new scheme).
If you have any thoughts on improvement or additional features, please let me know. If you have the time and the patience, I would love for any thoughts on better coding techniques as I am pretty much just teaching myself from what I see in other people's code.
Edited 1 time(s). Last edit at 02/06/2007 01:16PM by Azumandias.
I was able to pull the standard variables from the settings.tpl as you suggested and create a preview feature (though it only shows the first page in the new scheme).
If you have any thoughts on improvement or additional features, please let me know. If you have the time and the patience, I would love for any thoughts on better coding techniques as I am pretty much just teaching myself from what I see in other people's code.
Edited 1 time(s). Last edit at 02/06/2007 01:16PM by Azumandias.
Your IP address, domain or ISP has been blocked. Please contact the forum administrators.
Sorry, only registered users may post in this forum.