April 25, 200818 yr Hi, I want to have the functionality of php includes or ASP.net masterpages e.g. have one template page and content pages. I was interested in what options I have for this. I'm only doing a small site with around 10 pages. Thanks Andy
April 25, 200818 yr Hi Andy, Try the following in your main content area: <?php $page = stripslashes($_GET['page']); if (isset($page)) { if (file_exists("".$page.".php")) { //Change .php to the extension of choice for pages you want to include include "".$page.".php"; //Again, change extension if needed } else { echo "Error: Page Not Found."; } } else { include "mainpage.php"; //Change this to your 'news page', if you like... } ?>
April 27, 200818 yr <? function template($part) { switch ($part) { case "header": insert header stuff here break; case "footer": footer stuff here break; } } ?> Put the above in your template.php file and use: <?=template("header");?> to build bits - your template file can include as many bits of html as required.
Create an account or sign in to comment