Adding theme support to skins

What are Themes? Imagine you have a nice skin in green, but you'd like to allow your users to choose also blue or red color scheme. You could duplicate the skin files, change stuff and get a new skin for each new color. But alternatively, and what is more reasonable, you could create several themes for the same skin.

Technically a Theme is just a CSS file inside of a Skin. As the site picks another CSS file, that may change colors, images, fonts and the layout however you design it. A theme may consist of several CSS files, the requirement is that one of them is the main and the others are included from there.

So, to add theme support to your skin (which is somewhat required since Cotonti 0.0.2), you should first put your CSS file in your skin's folder (let's call it skins/your_skin) or a css subfolder in it(skins/your_skin/css).

If your skin contains just one theme, you can call it your_skin.css or style.css and put as we told before in the skin's folder. Then you need to edit skins/your_skin/your_skin.php and add a list of themes there:
$skin_themes = array('your_css_file_name' => 'Theme Name');
Cotonti will automatically expand that to skins/your_skin/your_css_file_name.css or skins/your_skin/css/your_css_file_name.css.

If your skin contains multiple themes, you should use multiple CSS files for them. In this case skins/your_skin/your_skin.php should contain something like this:
$skin_themes = array(
	'red' => 'Red',
	'green' => 'Green',
	'blue' => 'Blue'
);
So this theme set means that you have CSS files called red.css, green.css and blue.css located in skins/your_skin or skins/your_skin/css.

Another thing to remember about themes is that $cfg['defaulttheme'] in your datas/config.php must point to a valid existing CSS file, otherwise your site will die with fatal error.


1. KillerSneak  2009-07-13 18:43
Can this be bound on specific groups? Like the Donators group can choose a css that other groups can't? / same counts for whole templates.
2. TeknoGroup  2009-10-29 04:26
3. Panther  2010-08-11 22:50
thanks :)
Only registered users can post new comments