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

Zhris
User
Apr 12, 2011, 9:46 AM
Views: 5137
|
|
Re: [sunrise11] Need to change browser's title for one page
|
|
|
Hi, Personally I use PHP headers and footers, which I print using a http request. This way I can pass the title to the header, and use PHP to get/print it. HTML::Template fundamentally searches for the tag inside the HTML and replaces it with your value. If all you need to do is manipulate the title, then a simple search and replace might suffice over using HTML::Template. However, HTML::Template allows for "complex" templating using "in template" loops and so forth, therefore you may find a need for it in more complicated projects in the future. Its good to learn it. No Perl code goes inside the HTML. The idea is to keep Perl and HTML seperate. Mason would be the closest thing to doing that. Use the Perl script to bring everything together much like you probably did already, but you still haven't shown your whole code. E.g.:
use HTML::Template; my $title = 'This is the page title'; my $templateheader = HTML::Template->new(filename => 'Header.html'); $templateheader->param(TITLE => $title); my $main = 'This is the main content'; my $templatefooter = HTML::Template->new(filename => 'Footer.html'); print "Content-Type: text/html\n\n"; print "", $templateheader->output; print "$main"; print "", $templatefooter->output; Finally, I assume you didn't try to use CGI::Carp (if installed), which would provide you with an error message that could be used to derive whether HTML::Template is installed or not. Or check the error logs if you have access to them. Chris
(This post was edited by Zhris on Apr 12, 2011, 10:45 AM)
|
|
|
Edit Log:
|
|
Post edited by Zhris
(User) on Apr 12, 2011, 9:46 AM
|
|
Post edited by Zhris
(User) on Apr 12, 2011, 9:47 AM
|
|
Post edited by Zhris
(User) on Apr 12, 2011, 9:52 AM
|
|
Post edited by Zhris
(User) on Apr 12, 2011, 9:52 AM
|
|
Post edited by Zhris
(User) on Apr 12, 2011, 9:53 AM
|
|
Post edited by Zhris
(User) on Apr 12, 2011, 9:56 AM
|
|
Post edited by Zhris
(User) on Apr 12, 2011, 9:57 AM
|
|
Post edited by Zhris
(User) on Apr 12, 2011, 10:45 AM
|
|
|  |