Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Html Template CSS and CGI PERL

by Anneq (Vicar)
on Dec 28, 2004 at 14:35 UTC ( #417778=note: print w/ replies, xml ) Need Help??


in reply to Html Template CSS and CGI PERL

Put a link element in the header of your template file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <html> <head> <title><TMPL_VAR NAME=TITLE></title> <base target="_self"> <link rel="stylesheet" type="text/css" href="External.css"> </head> <body> .... </body>

You could go a step further and dynamically change your stylesheet by using a template variable for the sytlesheet filename.

For even more flexibility, use template toolkit instead of HTML::template. This would give you the ability to put variables in a stylesheet file, which would be processed before rendering to the browser:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <html> <head> <title>$Page.title</title> <base target="_self"/> <style type="text/css"> <!-- @import 'path/to/css/main.css'; [% PROCESS "path/to/css/theme.css" %] body { font-size: ${font_size}pt; } p { font-size: ${font_size}pt; } --> </style> </head> <body> .... </body> </html>

In the above example, the main stylesheet is imported, a stylesheet with variables (theme.css) is included, and then additional styles are explicitly added to override those in the first two stylesheets.

A drawback with this method is that the styles from theme.css show up when a user looks at the page source, because those styles get embedded in the html document.

Anne


Comment on Re: Html Template CSS and CGI PERL
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://417778]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2015-07-30 07:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls