|
Hello, Guest! - Register - |
|
| Articles | HTML & CSS Scripts | JavaScript Scripts | PHP Scripts | Forums Index | Mar 11, PST |
|
The first step is to make a new file and call it skins.php. This is the page you will be using to modify your skins. Copy and paste the code below to that file. You will need to modify this code to work with your skins. <?php $listofskins = array( 'Skin Name' => 'http://yoursite.com/skin1.css', 'Second Skin' => 'http://yoursite.com/skin2.css', 'Third Skin' => 'http://yoursite.com/skin3.css', ); if(isset($_GET['changeskin']) && isset($listofskins[$_GET['changeskin']])){ setcookie('siteskin', $_GET['changeskin'], time()+31536000, '/'); header('Location: '.$_SERVER['HTTP_REFERER']); die(); } ?> Find this part of the code. 'Skin Name' => 'http://yoursite.com/skin1.css', 'Second Skin' => 'http://yoursite.com/skin2.css', 'Third Skin' => 'http://yoursite.com/skin3.css', Give each skin a name then put the CSS file URL there. The first skin will be the default skin. If you are using any single quotes (') be sure to put a backslash (\) before it in order for this script to work properly. Note: You are free to add more then three skins just be sure each skin has a different name. Once that is complete get the path to the file skins.php. It should look something like this: /home/username/public_html/skins.php. Once you have the path to the file put it in the following code where it says DIRECTORY. <?php include('DIRECTORY'); ?> You will need to put that code at the top of every page that you want your skins to work on. Put the following code anywhere between the tags. <?php echo'<link rel="stylesheet" type="text/css" media="screen" title="Site Skin" href="'; if(isset($_COOKIE['siteskin'])){ echo $listofskins[$_COOKIE['siteskin']]; }else{ reset($listofskins); echo current($listofskins);} echo'">'; ?> You don't need to modify anything in the above code. The skin change form The following code is the form that your visitors can use to change the skin. <?php echo'<form action="" method="get" name="skinchanger"><select name="changeskin" onChange="document.skinchanger.submit()">'; foreach($listofskins as $skinname => $skinurl){ echo'<option value="',$skinname,'"'; if($_COOKIE['siteskin'] == $skinname){ echo' selected'; } echo'>',$skinname,'</option>'; } echo'</select></form>'; ?> How to add/remove any skins If you're getting tired of one of your skins you may remove it. First you need to open up the file you made called skins.php. Next, add/remove any skins then save your file. That's it! Thanks for reading. If you have any questions about this feel free to comment below or ask a question on our PHP forums.
| Written by: Thomas, Haily | Added: Jan 22 2010 | Last Modified: Jan 22 2010 | Views: 586 | Member Comments
| ||||||||||||||||||||||
|
Rabidish | KeliJo.net | Spicy-Sugar | Neoeditor | Daily Neopets | RockyRoadRules | Smiley Helper | Figmint | Windymill | Dash of Color | Moo Lovett | Guildpets | Arid Seas | The New Fearless | Paint-Pops.net | Neo Crave |
||||||||||||||||||||||