DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   PHP (http://www.daniweb.com/forums/forum17.html)
-   -   User based look & feel customization of site (http://www.daniweb.com/forums/thread159326.html)

sayaan Nov 24th, 2008 9:46 pm
User based look & feel customization of site
 
Hi everybody,
I'm new in this forum, I'm a PHP developer looking for good solutions for changing colors, fonts, styles of a site on the fly. The idea is, the user will be given options to customize his/her web site's font, color of various elements etc. and then the site will be built accordingly. The look and feel will vary based on the user.

Can anyone give me a good solution how this can be done in a very efficient way.

Sayaan

PomonaGrange Nov 24th, 2008 10:30 pm
Re: User based look & feel customization of site
 
There are a lot of ways that you could do this. One way would be to use sessions to store some info.

You can use a form like this one...

<form id="theme" action="" method="post">
<p>
 <select name="Color">
  <option>please select a Color ...</option>
  <option value="green">Green</option>
  <option value="blue">Blue</option>
  <option value="orange">Orange</option>
  <option value="purple">Purple</option>
 </select>

 <select name="Font">
  <option>please select a Font ...</option>
  <option value="green">Green</option>
  <option value="blue">Blue</option>
  <option value="orange">Orange</option>
  <option value="purple">Purple</option>
 </select>
<input type="submit" value="Change Theme">
</p>
</form>

Then place the following lines at the top of each php page....

<?
 session_start();

if(isset($_POST['Font']))  {$_SESSION['Font']        = $_POST['Font'];}
if(isset($_POST['Color']))  {$_SESSION['Color']        = $_POST['Color'];}

?>

Then in your <head> section echo your css theme....

<? 
echo "<style type 'text/css'>";

echo "p {color: ".$_SESSION['Color']." font-size: ".$_SESSION['Font']."}"; ?>
echo "</style>";

You would have to echo the session color and font throughout your css file.
You could also have predefined styles and use a similar session result.

Please note: I haven't tested this, but I think it might work.

There are probably better ways of doing this, but hope it helps.


All times are GMT -4. The time now is 12:36 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC