This is specific to MT, but the concent should be applicable to other blogging software.
Back when Statia and I were first skinning her site, Robyn used the sandwich anology(*) to explain how you "piece" out index.php for skinning.
1) the code at the top, up to but not including MTEntries [bread]
2) the MTEntries stuff [the all important sandwich filler]
3) the code after MTEntries to the end [bread]
Section 2 is the code that stays in index.php.
Section 1 is headerN.php (where N is the skin #).
Section 3 is footerN.php (where N is the skin #).
You can get more complicated and leave the javascript and the other code that is global to all of your skins in index.php. Then your header & footer would just contain the code that actually changes per skin, but it's not necessary.
(*) The sandwich analogy has been around for a while. Christine used it to explain skins to Robyn. And it's quite possible that Amy used it to explain it to Christine.
I've bolded the sections where you'll have to make changes. You can download this section of the tutorial here (right-click and save) if you're having problems copying & pasting from the site.
Other parts – these are all New Index Templates:
1) cookiecheck.php – This is the workhorse that points people to the right skin (if they are new and don't have a cookie or if they have a cookie already). This gets added to the top of index.php (and any other pages you want to match your skin). Note: I've used 10 here as the limit for the number of skins I have, but you can set it to either the exact number of skins you have or some other number.
<?
if (isset($newskin)) {
$newskin=(int)$newskin;
if ($newskin<1) $newskin=1;
if ($newskin>10) $newskin=1;
} elseif (isset($skin)) {
$newskin=(int)$skin;
if ($skin<1) $newskin=1;
if ($skin>10) $newskin=1;
} else {
$newskin=1;
}
$skin=$newskin;
$headervar = "/path/to/directory/where/your/skin/pieces/live/header";
$footervar = "/path/to/directory/where/your/skin/pieces/live/footer";
$extension = ".php";
?>
2) skins/index.php – This is your skin selector page. It basically has links to /skins/index2.php?newskin=N for each of your skins. It lets people see what skins you have to offer. cookiecheck.php goes at the top of this page too.
<?php include('/path/to/docroot/directory/cookiecheck.php'); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<? include($headervar.$skin.$extension); ?>
<table>
<tr>
<td valign="top" class="tableText">1: Description goes here <a href="/skins/index2.php?newskin=1">Make this one your skin</a>.</td>
</tr>
<tr>
<td valign="top" class="tableText">2: Description goes here <a href="/skins/index2.php?newskin=2">Make this one your skin</a>.</td>
</tr>
</table>
<? include($footervar.$skin.$extension); ?>
</body>
</html>
3) skins/index2.php – This is where people can test drive the skin they've selected. This has the same code at the top of the file as in cookiecheck.php. It also sets your cookie.
<?
if (isset($newskin)) {
$newskin=(int)$newskin;
if ($newskin<1) $newskin=1;
if ($newskin>10) $newskin=1;
} elseif (isset($skin)) {
$newskin=(int)$skin;
if ($skin<1) $newskin=1;
if ($skin>10) $newskin=1;
} else {
$newskin=1;
}
$skin=$newskin;
setcookie ('skin', "", time() – 3600);
setcookie('skin',$newskin,time()+(86400*365),'/');
setcookie('skin',$newskin,time()+(86400*365),'/','.your_domain.com');
$skin=$newskin;
$headervar = "/path/to/directory/where/your/skin/pieces/live/header";
$footervar = "/path/to/directory/where/your/skin/pieces/live/footer";
$extension = ".php";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<? include($headervar.$skin.$extension); ?>
<b>Like it?</b><br /><br />
Your skin number has been reset to '<?= $skin ?>.'<br /><br />
If you like it, journey on to the <a href="http://your_url.com/">main page</a> of this site and play with it a bit. If it's not quite what you want, you can always <a href="/skins/index.php">go back</a> and select another.
If you run into problems with any of the skins, <a href="contact_info_here">drop me a note</a>.
<? include($footervar.$skin.$extension); ?>
</body>
</html>
4) Example index.php (when I'm setting up skins for the first time, I like to name this test.php until I get all of the kicks worked out):
<?php
include('/path/to/docroot/directory/cookiecheck.php');
?>
<?
$headervar = "/path/to/directory/where/your/skin/pieces/live/header";
$footervar = "/path/to/directory/where/your/skin/pieces/live/footer";
$extension = '.php';
include('$headervar.$skin.$extension);
?>
<MTEntries>
blah blah blah
</MTEntries>
<? include('$footervar.$skin.$extension); ?>
</body>
</html>