Forum Moderators: coopster
<?php
//Main funciton for the Page layout
function layout($page_id) {
switch($page_id) {
default: //Default, ie when the page_id does not match with predefined cases
case '': //When it is null
case 'page1':
echo '<h2>page 1 content</h2>';
break;
case 'page2':
echo '<h2>page2 content</h2>';
}
}
?>
//then i call the content using
$page_id = $_GET['page']; //Get the request URL
layout($page_id); //Call the function with the argument
$page_id = isset($_GET['page'])?(int)$_GET['page']:0;
$template_file = 'templates/page-' . $page_id . '.tpl';
if( is_file($template_file) ) {
require($template_file);
// Do other stuff if necessary
} else {
header("HTTP/1.1 301");
header("location: http://www.example.com"); // Home page
}
exit();