Jump to content

Getting the Page Title for pages


TCombs

Recommended Posts

Hello, I'm new here and need some help.

I'm a beginner with PHP

 

Here's what I have....

 

The index page looks like this:

 

<? include("header.php"); ?>

<? include("sidebar.php"); ?>

<? include("main.php"); ?>

<? include("footer.php"); ?>

 

On all of the pages for the site, the only thing that will change will be:  <? include("main.php"); ?>

When viewing the home page, the title in the browser shows:  Home Page (which is what I want).

However, when clicking on links in the nav bar, I want the title to reflect those page names.

 

For example, the code above displays the home page, but then if you click on (for example) "Bio's" in the navigation bar, it will take you to the Bio's page, obviously.  the link for that menu item is:  bio.php.

 

The bio.php page looks like this:

 

<? include("header.php"); ?>

<? include("sidebar.php"); ?>

 

<div> All the data and formatting for this page </div>

 

<? include("footer.php"); ?>

 

.............

 

I would like to put some php code in the header that will automatically detect the title of each page, how can I do this?

 

Should I put <? title=Bio's Page ?> (or whatever page) at the top of each page, then call to it somehow from the header?

 

Any help would be appreciated.

 

 

 

 

Link to comment
Share on other sites

Chrispos, thanks for your response!

 

How would I write this for multiple pages?

 

In the header.php file, what would I put in the title tag? (if anything)

 

And for each of the pages, is that where I would put the php code you gave me?

Meaning, would I go to the bio.php and at the top enter:

 

<? if {bio.php $title = 'Bio ETC'; { else { $title = 'Home Page' } echo "$title";  ?>

 

Then for the news.php page, i would enter this at the top:

<? if {news.php $title = 'Bio ETC'; { else { $title = 'Home Page' } echo "$title";  ?>

 

 

Am I on the right track?..lol 

Thanks in advance.

 

 

 

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.