Thanks in advance
Getting the Header to display different page titles
Moderator: General Moderators
-
alex.saidani
- Forum Newbie
- Posts: 7
- Joined: Mon Jan 25, 2010 2:15 pm
Getting the Header to display different page titles
I have written a script for my website's header that is completely seperate to all the pages, this was to make it easier for me to edit the header, rather than going into every page. However the problem is i can only get this script to dispaly one title for every single page. I was just wondering if anyone could offer any help on how to get the header to display a different title for each page.
Thanks in advance
Thanks in advance
Re: Getting the Header to display different page titles
A couple ways:
1) In your header script, you could figure out the filename of the current page (something like: basename($_SERVER['REQUEST_URI']) could work). Then display a particular title depending on the filename
2) A more flexible way would be to include the title of the page in the file that is including the header script:Then have your header.inc file work with $title.
1) In your header script, you could figure out the filename of the current page (something like: basename($_SERVER['REQUEST_URI']) could work). Then display a particular title depending on the filename
2) A more flexible way would be to include the title of the page in the file that is including the header script:
Code: Select all
<?PHP
$title = "This is my blog";
include "header.inc";
... rest of the page
?>Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
alex.saidani
- Forum Newbie
- Posts: 7
- Joined: Mon Jan 25, 2010 2:15 pm
Re: Getting the Header to display different page titles
Thanks for the help, i intended to put the title part inside the header.
This is what i tried, did not work though, i clearly am doing something wrong :/
This is what i tried, did not work though, i clearly am doing something wrong :/
Code: Select all
<title>
<?php
$title= basename($_SERVER['REQUEST_URL'])
if ($title == "index.php") {
echo "Moovie :: Home";
}
?>
</title>
Re: Getting the Header to display different page titles
It's REQUEST_URI (you-are-eye) not URL (you-are-ell)
Please use [syntax=php][/syntax] tags when posting PHP code.
Please use [syntax=php][/syntax] tags when posting PHP code.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.