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!

Link to comment
Share on other sites

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>";

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.