CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [Zhris] Need to change browser's title for one page: Edit Log



sunrise11
Novice

Apr 14, 2011, 6:18 AM


Views: 6179
Re: [Zhris] Need to change browser's title for one page

Chris,

Thanks to you, I'M VERY CLOSE!!!

I'm getting <?php echo $title ?> in the browser's title so the PHP directive isn't working quite yet.

I have it set up a little differently than your way because I didn't want to modify the original code too much if possible.

Here's how it's set up (with my changes in bold):

header.php


Code
<?php  
if (isset($_GET['Title'])) {
$title = $_GET['Title'];
}
else {
$title = 'My Documents';
}
?>

<html xmlns="http://www.w3.org/1999/xhtml">
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>

<title><?php echo $title ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name='description' content='Description' />
<meta name="keywords" content="Keywords" />
<link href="file.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div><center>
<img src="header.gif" alt="header" border="0" />
</center>
</div>


Perl Code (with my changes in bold):

L43 =

Code
# This file is the header to be displayed on all pages. $gHeader = "my-root-directory-here/header.php";


L81-101 =

Code
### Subroutines ### 

# insert a text file in the result HTML
sub insert {
my $trigger = shift;
if ($trigger eq "header") {
use LWP::Simple;
my $header = "header.php?$title";

print "Content-type: text/html\n\n";
open(FILE,"<$gHeader") || return 0;
print get($header);
} elsif ($trigger eq "footer") {
open(FILE,"<$gFooter") || return 0;
} elsif ($trigger eq "info") {
open(FILE,"<$gInfo") || return 0;
} else {
return 0;
}
while (<FILE>) { print; }
close(FILE);
return 1;
} # insert



L260-262 =

Code
# view list of a user (by user or guest) 

use LWP::Simple;

my $header = "header.php?Title=$fullname\'s Document";
print "Content-type: text/html\n\n";
print get($header);


sub view {
my $test = &auth($gF{'USERNAME'},$gF{'AUTH'});
if (!$test) { return; }


L260-262 is where I want the title to be different than the other pages so if users save a shortcut to the page, they will have a specific reference (ex: Mary's Document). The other pages are generated from L81-101 (subroutines).

Do you see any reason why the title wouldn't output properly using this method?

Is there a conflict between $header and $gHeader?


Code
# insert a text file in the result HTML 
sub insert {
my $trigger = shift;
if ($trigger eq "header") {
use LWP::Simple;
my $header = "header.php?$title";
print "Content-type: text/html\n\n";
open(FILE,"<$gHeader") || return 0;
print get($header);
} elsif ($trigger eq "footer") {


I'm so close!


(This post was edited by sunrise11 on Apr 14, 2011, 8:57 AM)


Edit Log:
Post edited by sunrise11 (Novice) on Apr 14, 2011, 6:38 AM
Post edited by sunrise11 (Novice) on Apr 14, 2011, 6:40 AM
Post edited by sunrise11 (Novice) on Apr 14, 2011, 6:46 AM
Post edited by sunrise11 (Novice) on Apr 14, 2011, 6:55 AM
Post edited by sunrise11 (Novice) on Apr 14, 2011, 6:57 AM
Post edited by sunrise11 (Novice) on Apr 14, 2011, 8:26 AM
Post edited by sunrise11 (Novice) on Apr 14, 2011, 8:29 AM
Post edited by sunrise11 (Novice) on Apr 14, 2011, 8:49 AM
Post edited by sunrise11 (Novice) on Apr 14, 2011, 8:51 AM
Post edited by sunrise11 (Novice) on Apr 14, 2011, 8:52 AM
Post edited by sunrise11 (Novice) on Apr 14, 2011, 8:57 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives