views:

133

answers:

1

Hello everyone,

I am trying to find out a solution for implementing themes selector on my website build using PHP.

After logging in a user is presented with the available themes, and the one that is selected get stored in his profile.

But if a user is willing to change the colour of his current theme with his own customized colour, then how shall I do this.

I looked at yui App theme but don't know if it will suit my needs. Any help is greatly appreciated.

Thanks

+3  A: 

CSS can be output from a PHP script so just do something like:

css.php:

<?php
session_start();
$theme = load_theme($_SESSION['userid']);
header('Content-Type: text/css');
?>

body {
  font-family: Verdana, sans-serif;
  color: <?php echo $theme['base-color']; ?>;
}

...

The 'theme' can just be a palette of colours or you can have a set of stylesheets that are more radically different. The user chooses one and then optionally chooses colours for it.

All this should be supported by correct versioning so the user only downloads the stylesheet when they change preferences or the base stylesheet changes.

Preview is a little harder. For this you'll probably need a customized stylesheet just for this purpose and use Javascript to dynamically update the stylesheet on the fly so the user can see the changes immediately. This is a far more substantial piece of work.

cletus
thanks cletus :)
Gaurav Sharma