View Full Version : Skinning


freakEgurl
11-05-2003, 11:27 PM
Before you start.
In case you mess up, HAVE AN EXTRA SET OF CONTENT ALL FILES! .. i had to find out why the hard way when converting my site into php and adding query strings.
DO NOT USE IFRAMES! They will mess you up, big time.
You need ONE set of content files.
All files MUST be .php. If your site requires a diffrent extention for php, edit this line is cookiecheck.php '$extension = ".php";' to whatver you need it to. Also, change the extentions everywhere else, like in the includes.
And, php MUST be enabled.
First, take all your pages and remove anything that part of the layout. So, its just the content.
At the top of ALL your content files paste this.
<?php include ("home/user/public_html/skins/cookiecheck.php");?>
<?php include($headervar.$extension); ?>

In the first line, be sure to make that a local path to cookiecheck.php. Or you'll get php errors.

And at the bottom, paste this >
<?php include($footervar.$extension); ?>

when coding your layout, Everything that goes ABOVE the content goes into header.php Anything BELOW the content is in footer.php

Also, make sure everything that is skinned is a .php file. Other wise, it wont work
--

Create a file called cookiecheck.php and paste this code into it.

<?

$total_skins = 1;
$default_skin = 1;

if (isset($_REQUEST['newskin'])) {
$newskin=(int)$_REQUEST['newskin'];
if ( ($newskin<1) OR ($newskin>$total_skins) )
$newskin=$default_skin;
} elseif (isset($_REQUEST['skin'])) {
$newskin=(int)$skin;
if ( ($skin<1) OR ($skin>$total_skins) )
$newskin=$default_skin;
} else $newskin=$default_skin;

$skin=$newskin;
setcookie ('skin', "", time() - 3600);
setcookie('skin',$newskin,time()+(86400*365),'/');
setcookie('skin',$newskin,time()+(86400*365),'/','.yourdomain.net');
$skin=$newskin;


$headervar = "/home/user/public_html/skins/$newskin/header";
$footervar = "/home/user/public_html/skins/$newskin/footer";
$extension = ".php";
?>


$total_skins = 1; > the total amought skins you have
$default_skin = 1; > the default skin
$headervar = "/home/user/public_html/skins/$newskin/header";
$footervar = "/home/user/public_html/skins/$newskin/footer"; .. Change those both to local paths to your skins folder. Keep the stuff after /skins.

setcookie('skin',$newskin,time()+(86400*365),'/','.yourdomain.com'); ... your domain. Keep that dot at the beggining. If you have a subdomain, it would be .sub.domain.net or whatever it really is. If your hosted with a slashy thing like example.com/yoursite, it would be, .example.com/yoursite/
--

go to ftp. Create a folder called skins. Put cookiecheck.php in that folder. Create a folder called 1. That is where skin number 1 goes. All images, header.php/footer.php files go there.
All skins are in thier own folder. Skin 1 goes into /skins/1. Skin 2 goes into /skins/2

To get to a new skin, go to, http://yoursite.com/index.php?newskin=# that # replaces the skin number, obviolsly.
--


How it works.

Your content files include header/footer files from diffrent skins useing variables. Cookiecheck.php sets the cookies, so everytime you come back, or switch a page, you're still using the same skin. Very simple if you get it.


I hope that makes sence. heh.

isi333
12-24-2003, 06:07 PM
I'm sorry if I'm speaking out of turn here, but shouldn't you credit domesticat.net (http://www.domesticat.net), because she wrote the script itself?

SimplyGirlyGirl
01-26-2004, 08:55 PM
This looks suspiciously like the domesticat tutorial on how to skin blogs

http://www.domesticat.net/skins/howto.php