|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Ok, so CGI.pm claims to have limited support for CSS sheets, so i decided to test this, and indeed you can apply certain styles to a newly generated page. However, one of the most imporant styling tags, <DIV> is not fully supported.
I have the following code which doesn't work. Can anyone provide insight. Code:
#!/usr/bin/perl -w
use CGI qw(:all);
use CGI::Carp qw(fatalsToBrowser);
my $cgi = new CGI;
print header();
print start_html(
-title=>'Confirmation Page',
-dtd=>"-//W3C//DTD HTML 4.0 Transitional//EN",
-style=>{'src'=>'/~spendhar/css/netflixxx.css'}),
div(-class=>{'bodyMain'},
p({-class=>'bodyText'},"This should work",
h1('Hope this works'),
end_html()));
The problem is how to access classes within <DIV> because CGI.pm won't allow you to do that. |
|
#2
|
||||
|
||||
|
CGI.pm doesn't export it's div() method by default.
Use the object oriented CGI interface, or import the div method as well by putting it in the "use" statement Code:
#!/usr/bin/perl
use CGI;
#use CGI ('div'); #import the div() method
my $q=CGI->new();
print $q->div(
{-class=>"foo"},
$q->p("Here's a paragraph")
);
print CGI::div(
{-class=>"foo"},
$q->p("Here's a another paragraph")
);
|
|
#3
|
|||
|
|||
|
thanks Hero Zzyzzx, i actually managed to get it to work without resorting to cgi.pm (which i find is more cumbersome for my needs anyway).
I did have another question for you though. Is it possible to generate a html page via perl which also uses SSI includes ? The reason i ask is that i have my header and footer in a .shtml which i call via SSI include. Now that i'm using perl to generate new pages, i would like to dump my SSI include in the code and have perl actually interprete and use SSI to generate the header and footer. An example of my code is : Code:
#!/usr/bin/perl use CGI; use CGI qw(:all); use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n"; print "<html><head>\n"; print "<!--#set var=\"Doc_Title\" value=\"Net FlixXx Online\" -->\n"; print "<title> <!--#echo var = \"Doc_Title\" --> </title>\n"; print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n$ print "<link href=\"/~spendhar/css/netflixxx.css\" rel=\"stylesheet\" type=\"text/css\">\n"; print "</head>\n"; print "<body leftmargin=\"0\" rightmargin=\"0\">\n"; print "<div class=\"mainFrame\">\n"; print "<!--#include virtual=\"/~spendhar/***1/header.shtml\" -->\n"; print "<div class=\"bodymain\">\n"; print "<p class=\"bodyTitle\"> News </p>\n"; print "<p class=\"bodyText\">Hello, world!</p>\n"; print "</div></div></body></html>\n"; The code above doesn't work with the includes, i guess perl doesn't know how to handle them. Any workarounds to this problem ? |
|
#4
|
|||
|
|||
|
Have you tried looking at the html::template perl module? It makes writting sections of html a lot easier.
|
|
#5
|
||||
|
||||
|
Quote:
Yes it does. I use HTML::Template for everything I develop. But there's also CGI::SSI on www.cpan.org. Try that out, but I also suggest picking up HTML::Template. |
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > Using <Div> and CSS in CGI.pm |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|