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
Share on other sites

Guest elthomo

I'm a php learner so this may not be correct but...... Could you not put an include with the header(html banner and stuff) above where the content starts and the same for the footer but below on each page you call ?

Link to comment
Share on other sites

Hi,

 

Please check rewrite rules and .htaccess changes on google. It will be easy with one rule like below

 

([^/]*)/([^/]*)/ index.php?page=($1)/($2)

 

To use .htaccess, you should have allowoverrideall setting enabled in httpd.conf. Please google around.

 

hth

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.