Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 04-05-2009, 12:07 AM Title of Page
konetch's Avatar
Ultra Talker

Posts: 258
Trades: 0
I want a different title to appear for every page. This is my header.php that I include at the top of every page

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="http://www.konetchreport.com/external/external_style.css" type="text/css">
<title>KonetchReport</title>
</head>

<body>
<!--Start Container-->
<div align="center">
<div id="container">
<div align="left">
I want to change the title so it appears different on every page. How do you do this?

Thanks,
Alex Konetchy
http://www.konetchreport.com
konetch is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-05-2009, 12:16 AM Re: Title of Page
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
This is one way:
PHP Code:
switch($_SERVER['PHP_SELF'])
{
     case 
'/index.php':
          
$title 'Home';
          break;
     case 
'/page.php':
          
$title 'Page';
          break;

__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 04-05-2009, 12:17 AM Re: Title of Page
konetch's Avatar
Ultra Talker

Posts: 258
Trades: 0
Yeah I did that, but I have a large amount of pages and was wondering if there are any easier ways of changing the title.

Thanks
konetch is offline
Reply With Quote
View Public Profile
 
Old 04-05-2009, 12:29 AM Re: Title of Page
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Assuming that the title can be derived from the file name, this will get the name of the file without slashes or the .php extension:
PHP Code:
$page end(explode('/' $_SERVER['SCRIPT_NAME']));

$title str_replace('.php'''$page); 
Without more information about your pages or file naming scheme that's the best I can do. If it is the case that you are pulling your pages from a database, you might want to include a page title column in your table.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 04-05-2009 at 12:32 AM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 04-05-2009, 12:34 AM Re: Title of Page
konetch's Avatar
Ultra Talker

Posts: 258
Trades: 0
I think that should work.

Thanks for the help
konetch is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Title of Page
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15752 seconds with 12 queries