Ever had to transfer a very large number of flat files to a CMS? There are many ways to achieve this, but sooner of later you will have to do some grunt work with code. One of the solutions involves creating a naked version of your content with a very basic navigation system and a COPY CODE link.

If you create your archive using php, you can include this bit of code on your pages to make each one, just one click away from displaying source code:

1. Create this bloc of php in the top of the template file

<?phpfunction curPageURL() {
$pageURL = ‘http’;
if ($_SERVER["HTTPS"] == “on”) {$pageURL .= “s”;}
$pageURL .= “://”;
if ($_SERVER["SERVER_PORT"] != “80″) {
$pageURL .= $_SERVER["SERVER_NAME"].”:”.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
?>

2. Add this link to all your pages

<a href=”view-source:<?php echo curPageURL(); ?>” target=”_blank”>View source of current page</a>