Page Title and Page Name....

Status
Not open for further replies.

Sean

‫‫‫‫‫‫  ‫  Don't Worry, Be Happy
Dec 12, 2011
1,121
405
Ok as you know I do not know anything about PHP. So I was wondering if someone can help me. I want to have my website saying the website name like so:

Website Name - Page Name

I could sit and put the correct info on each page. but I want it to be a bit more professional, so I have my Index Page like so :




PHP:
<?php
 
require_once 'Website_Includes/header.php';
 
/* CONFIG */
 
$path = 'Website_Pages/'; // path to the folder where you store pages
 
$default_page = 'Home'; // if no page is set, this will be included
$default_404_page = '404'; // if the page does not exist, this will be included
 
/* SLAVE */
 
if(empty($_GET['page'])) { // check if you have set the page in the URL
 
    $page = $default_page; //set the default page set in the config since no page was set in the URL
 
}else{
 
    // the code below checks if the page contains only letters, numbers, underscores and/or dashes
    // it also checks if the file exists
 
    $page = (preg_match('/[^a-zA-Z0-9\ _-]/', $_GET['page']) || !file_exists($path . $_GET['page'] . '.php') ? $default_404_page : $_GET['page']);
 
}
 
// includes the page correct page
 
require_once $path . $page . '.php';
 
require_once 'Website_Includes/footer.php';



I want to have the Main title in there and then on each page I add a small piece of code that extends the title with that page name ? If you understand - Please help :p
 
Status
Not open for further replies.

Users who are viewing this thread

Top