Jump to content

Page titles


foucquet

Recommended Posts

i guess that there is some kind of way that the pages are different from each other? you can use that difference to assign different names before the include and within the include refer to that with a variable

 

for example, the pages are different by url and the urls are: website.com?page=1 and website.com?page=2 etc.

 

you can ask that name and change it with:

 

if ($_GET['page'] == '1') $title = 'The name of the first page';
if ($_GET['page'] == '2') $title = 'The name of the second page';

 

and within your include you place

 

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

 

something like this?

Link to comment
Share on other sites

Perhaps the simplest way would be to set a variable before the include:

 

$page_title = 'Your title here';
require 'header.php';

 

Then check within the template file if the variable's been set:

 

<title><?php if (!empty($page_title)) echo $page_title; else 'Default title here'; ?></title>

Link to comment
Share on other sites

<?php
$title1 = "Title for Page 1";
$ip = $_SERVER['REMOTE_ADDR'];
?>

<HTML>
<HEAD>
<TITLE><?php echo $title1; ?></TITLE>
</HEAD>
<BODY>
<h1><?php echo $ip; ?> is your IP address....</h1>
</BODY>
</HTML>

 

... is what I briefly had in mind.

 

Oookay... What's with the IP?

Link to comment
Share on other sites

Perhaps the simplest way would be to set a variable before the include:

 

$page_title = 'Your title here';
require 'header.php';

 

Then check within the template file if the variable's been set:

 

<title><?php if (!empty($page_title)) echo $page_title; else 'Default title here'; ?></title>

 

OK so a couple of experiments tell me this is not only the easiest, but also the simplest solution, and works perfectly - well it did after I got over the problem of putting a single quote in the title  :D

 

Thanks MrAdam

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.