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
https://forums.phpfreaks.com/topic/211698-page-titles/#findComment-1103569
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
https://forums.phpfreaks.com/topic/211698-page-titles/#findComment-1103571
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
https://forums.phpfreaks.com/topic/211698-page-titles/#findComment-1103608
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
https://forums.phpfreaks.com/topic/211698-page-titles/#findComment-1103640
Share on other sites

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.