Color.module has the ability to customize and generate stylesheets in a snap.
Color.module comes stocked with 2 very powerful color replacement methods.
- Methods are declared in your theme's
hook_color function inside template.php (in /themes/THEMENAME).
- can be declared in the order you wish for them to work.
- can have custom options put into them to make them behave differently.
Color replacement methods
Tag
Searches and replaces tags in CSS according to fieldname.
Shift
An automated "color shifting" system. Requires a fieldname called 'base', and a color for that fieldname in all schemes.
Furthermore, it's essential that you declare a 'reference scheme' in your hook_color so there is something to compare colors to.
Declaring your replacement methods
Open /themes/THEMENAME/template.php. Inside the THEMENAME_color() function there you will have a $color array where you declare 'replacement methods'. Here is an example which implements both.
function THEME_color() {
$color = array(
/**
* 'replacement methods'
* Declare replacement replacement methods in the 'replacement methods' array,
* in the order you want them to work.
* They are comprised different algorithms to change your colors.
* replacement methods like 'shift' can accept different options and behave differently.
* To change the order of the replacement methods color replacement, put them in order.
*/
'replacement methods' => array(
/**
* 'shift' method
* Requires 'base-only', or 'base', and/or'link' and/or 'text'
*/
'shift' => array('base', 'text', 'link'),
/**
* 'tag' method
* Replaces custom tags in stylesheet based on fieldname.
*/
'tag' => TRUE,
),
// ... Rest of your $color code
);
return $color;
}
With this code, color.module will run shift on the stylesheet, then tag (they run in the order they're declared). Shift has the options base, text and link, which means that the fields array in hook_color will have the field names base, link and text. Because tag takes needs no extra options, it is set to TRUE.
Examples
Examples can be found by downloading this module and looking at the hook_color's in the example theme's template.php file. Which is located in /modules/COLORMODULE/examples
Example themes using both shift and tag: FriendsElectric, Nista, Splender
Example themes using only shift: Garland, Minnelli, Spooner (special 'base-only' option, uses only one field.)
Example themes using only tag: Cleanstate, Simpla