Jump to content

Setting page title from file included later on...


cgm225

Recommended Posts

For my site I have been using a header.php and footer.php file to form a website "wrapper" in between which unique files are included.  The header.php file includes the title and meta data, etc.  So, for example, my main page would be generated by a file that includes three files:

 

include_once "header.php";
include_once "frontpage.php"
include_once "footer.php";

 

Or similarly, I could generate an e-mail page as such:

 

include_once "header.php";
include_once "emailMe.php"
include_once "footer.php";

 

However, here is my question.  Is there a way, without using output buffering or templates (like Smarty), to set the webpage title (that found between the <title> tags within the header.php file) from the second included file/unique file found in between the header and footer?

 

Right now I am doing this with output buffering, but I am trying to get away from that.  Should I be creating my website "wrapper" a completely different way?

 

Thank you all in advance!

I normally handle that case like this:

 

<?php
$title = "This is the page title";
include_once "header.php";
include_once "emailMe.php"
include_once "footer.php";

 

And then modify the header.php file to include this line in the appropriate location:

 

echo "<title>". $title. "</title>";

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.