Jump to content

PHP Include Site Template :/


Spitfire

Recommended Posts

I have a site running this code:

 

  
HEADER


// Content Loaded Here

<?php
    $pathToMainPage = "news/news.php";
    $pathTo404Page = "error.php";
    if(isset($_GET['page']))
    {
        $pathToIncludePage = $_GET['page'].=".php";
        if(file_exists($pathToIncludePage))
        {
            include $pathToIncludePage;
        }
        else
        {
            include $pathTo404Page;
        }
    }
    else
    {
        include $pathToMainPage;
    }
?>

// End Content

FOOTER

 

This outputs all pages as index.php?page=PageName. My question is whats the easist way to make a template that will allow pages to be displayed like this.

domain.com/category1/page1/ using a common header / footer etc.

 

atm i have domain.com/index.php?page=category1/page1

 

any help would be great, thanks!

Link to comment
https://forums.phpfreaks.com/topic/96145-php-include-site-template/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.