PDA

View Full Version : PHP skin



Bakaelite
April 14th, 2004, 17:06
most personal sites allow users to change the theme or skin of the site. I know they use PHP, but I'm just a beginner. does anyone know how to do it? or maybe a link to a tutorial?

kabatak
April 14th, 2004, 20:51
they use CSS, basically, they use different CSS files, say you have 3 CSS files, A,B,C.. on A, you put background color to red, on B, you color it yellow, on C, green, and so on. And you just load them separately using a link or perhaps PHP to load them dynamically.

Bakaelite
April 14th, 2004, 22:04
yea... i want to make my page a dynamic site. i got my css skins ready but i need to learn how to use php

link92
April 15th, 2004, 06:29
I had to do one for a while back at codingforums, I'll just get the code...



If in the file you want the switcher you have this at the top:

<?PHP

switch ($_GET['style'])


{

case 'theme1':
#replace theme1.css with the style sheet location
$strTheme = 'theme1.css';
break;

case 'theme2':
#replace theme2.css with the style sheet location
$strTheme = 'theme2.css';
break;

default:
#replace default.css with the style sheet location
$strTheme = default.css';
break;


}

?>
and to the link to the style sheet as
<link rel="stylesheet" type="text/css" src="<?PHP print $strTheme; ?>" />


This script works so if the file is index.php you put index.php?style=theme2 and then it will show you what you have replaced theme2.css with, if you put theme1 then it shows what you have replaced theme1.css with and if what you put doesn't exist or you put nothing, it uses the default.