Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

using CGI.pm for LINK tag for Stylesheet

by LameNerd (Hermit)
on Jun 16, 2003 at 06:32 UTC ( [id://266114]=perlquestion: print w/replies, xml ) Need Help??

LameNerd has asked for the wisdom of the Perl Monks concerning the following question:

How do I use CGI to generate
<head>
    <title>BLAH BLHA</title>
<link rel="stylesheet" type="text/css" href="mycss.css" />
</head>
I mean using CGI.pm is the right thing to do right?
Or should I just skip it and do this
print <<HTML; <head> <title>BLAH BLHA</title> <link rel="stylesheet" type="text/css" href="mycss.css" /> </head> HTML
and forget all about doing ...
$cgi->start_html ( -head=> ... bunch of switches I can't keep straight +... );

Replies are listed 'Best First'.
Re: using CGI.pm for LINK tag for Stylesheet
by tedrek (Pilgrim) on Jun 16, 2003 at 06:43 UTC

    I'd suggest using HTML::Template rather than CGI.pm for the HTML aspects ( or another Templating system). Being able to seperate your code from your HTML really becomes nice later :) I see very few people actually using CGI.pm for generating the html, it's pretty much used just for the parameter parsing.

      I'd like suggest to use Embperl or Mason for embedding Perl code into HTML page. See my post about it.
            
      --------------------------------
      SV* sv_bless(SV* sv, HV* stash);
      
Re: using CGI.pm for LINK tag for Stylesheet
by PodMaster (Abbot) on Jun 16, 2003 at 06:50 UTC
Re: using CGI.pm for LINK tag for Stylesheet
by kutsu (Priest) on Jun 16, 2003 at 19:19 UTC

    You might try Ovid's Course.

    "Pain is weakness leaving the body, I find myself in pain everyday" -me

Re: using CGI.pm for LINK tag for Stylesheet
by hacker (Priest) on Jun 17, 2003 at 02:32 UTC

    This should get you started with a few different ideas. I use this code on a production site, and the two stylesheets mentioned fall back gracefully for all browsers tested; 14 total.

    (Pardon the indenting, this is purely for PM formatting only)

    $cgi->start_html(-title => 'Your Snazzy Page', -head => [$cgi->style ({-type => 'text/css', -media => 'all'}, '@import "css/your.css";'), # nonstandard browsers, wget, LWP $cgi->Link({'rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'css/nonstandard.css'}), + # only for printing $cgi->Link({'rel' => 'stylesheet', 'media' => 'print', 'type' => 'text/css', 'href' => 'css/print.css'}), $cgi->Link({'rel' => 'shortcut icon', 'href' => 'favicon.ico', 'type' => 'image/x-icon'})], -author => 'you@foo.com', -base => 'true', -bgcolor => '#fff', -meta => { 'keywords' => 'this that', 'copyright' => 'Foo, inc.', 'Cache-Control' => 'no-cache', 'robots' => 'index,follow'}); # Print the environment passed print "<!--\n"; print map{"$_ is $ENV{$_}\n"} sort keys %ENV; print "-->\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://266114]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-24 22:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found