[eluser]Amitabh Roy[/eluser]
I general have a directory called assets which is in the same level as the system directory.
Inside the assets I put the css, js, images directories.
For one project I needed to have multiple themes , so I had a theme directory inside the assets directory. The theme directory contained multiple themes(directories), each of which is a directory containing the css and images in separate folders. The css name is the same in all the themes , so the theme directories have the structure
assets/themes/blue_theme/style.css
assets/themes/blue_theme/images/
assets/themes/yellow_theme/style.css
assets/themes/yellow_theme/images/
assets/themes/green_theme/style.css
assets/themes/green_theme/images/
Now to be able to refer to the theme directory, I create a custom config file and put the path to the themes folder as a config entry.
Code:
$config['themes_dir'] = 'http://localhost/mycodeignitersite/assets/themes/';
I also store the themes entries in a separate theme table so that users can choose the theme.
So for a given user who has chosen a green theme, the css is generated as follows
Code:
//lets say $userTheme is the selected user theme
<link href="<?php echo $this->config->item('themes_dir').$userTheme.'/style.css';?>" rel="stylesheet" type="text/css" />
Of course this approach is applicable for only css based themes where the html structure/layout of the page doesn't vary much. For themes which will use a complete different set of layouts(which means different views) a similar approach can be taken.