Jump to content
xisto Community
Sign in to follow this  
iGuest

Global Page Title w/ PHP

Recommended Posts

You might notice that on most professional sites, the title looks something like:

SiteName :: Page Title

This is conviently done, and it can be change with one file for the whole site, if you set it up right. Here's how.

Create a page in the root folder of your site with PHP installed. Name the page GlobalTitle.php.

(You can also include this in another file if you rather, like say settings.php, config.php, or functions.php. Do this if you plan on including other things in the file.)

In the file, paste this code:
<?phpfunction PageTitle() {global  $PageTitle; //on each page, we'll set this variable to be the second part of the Title$SiteName = "YourSiteNameHere";//SiteName for title.  echo "<title>" . "$SiteName" . " :: " . "$PageTitle" . "</title>"; }?>

Now inside the header of each page, do this:

<?$PageTitle = "Whatever title this might be";include($_SERVER['DOCUMENT_ROOT'].'/GlobalTitle.php');  PageTitle();?>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.