CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 5th, 2003, 06:14 AM
Metatron Metatron is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 4 Metatron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Linking an external CSS stylesheet to a Perl generated HTML document

G'day sports ...

I've had a look-see on the internet for an answer to this, and I haven't found one yet, so maybe you can help. I have installed a guestbook at my site, which uses Perl (it was an 'off-the-shelf' one from here). The problem is that I can link the guestbook pages to the site stylesheet, but when you add to the guestbook it generates a very plain looking [i.e. unformatted] confirmation page that looks very out of place. My question is, therefore, how (and I'm assuming that it's possible) do you link a perl generated webpage to an external CSS document, so that it's formatted to look the same as the rest of the site?

I am new to perl (i.e. have no knowledge of it), but would assume that the relevant part of the script involves the 'print' command. I don't have the script to hand, but the instructions are along a similar line to this ...

PHP Code:
print "Content-type: text/html\n\n";

   print 
"<html>\n <head>\n  <title>Results of Search</title>\n </head>\n";

   print 
"<body bgcolor=\"WHITE\">\n <center>\n  <h1>Results of Search in $title</h1>\n </center>\n";

   print 
"Below are the results of your Search in no particular order:<p><hr size=7 width=75%><p>\n"


... and that the link to the external stylesheet would go in there somewhere. Any suggestions will be gratefully received, and aplogies if I'm missing anything obvious.

Reply With Quote
  #2  
Old December 5th, 2003, 06:23 AM
Ex-RoNiN Ex-RoNiN is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 130 Ex-RoNiN User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 48 m
Reputation Power: 6
A link to an external stylesheet goes into the <head>, doesn't it? I would think that if you just put print in front of the necessary tags that specify the external stylesheet, then it should work, since it knows that it is html.

Try putting the stylesheet reference into the appropriate place with the print command in front of it, it ought to work that way.

Reply With Quote
  #3  
Old December 5th, 2003, 07:39 AM
Metatron Metatron is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 4 Metatron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for your reply. Y'know I actually think that I tried that, kinda like this ...

PHP Code:
print "Content-type: text/html\n\n";

   print 
"<html>\n <head>\n  <title>Results of Search</title>\n </head>\n";

   print 
"<link href=\"../beaver.css\" hreflang=\"en\" rel=\"stylesheet\" type=\"text/css\" charset=\"UTF-8\" >\n";

   print 
"<body bgcolor=\"WHITE\">\n <center>\n  <h1>Results of Search in $title</h1>\n </center>\n";

   print 
"Below are the results of your Search in no particular order:<p><hr size=7 width=75%><p>\n"


... but this made the script sick. Whenever I tried to add to the guestbook, it errored and informed me that I should contact the site administrator. Which is me, and I'm no use, I can tell you ...

Before that, I had tried to insert the link to the CSS document in the <head></head> line above, as I would with a regular HTML document, but didn't work either. Any ideas?

Reply With Quote
  #4  
Old December 5th, 2003, 08:50 AM
mlh2003's Avatar
mlh2003 mlh2003 is offline
Y? Y!?
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2003
Location: Brisbane, Australia
Posts: 1,571 mlh2003 User rank is Sergeant Major (2000 - 5000 Reputation Level)mlh2003 User rank is Sergeant Major (2000 - 5000 Reputation Level)mlh2003 User rank is Sergeant Major (2000 - 5000 Reputation Level)mlh2003 User rank is Sergeant Major (2000 - 5000 Reputation Level)mlh2003 User rank is Sergeant Major (2000 - 5000 Reputation Level)mlh2003 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 11 h 35 m 7 sec
Reputation Power: 43
As Ex-RoNiN mentioned, the <link href...> tag needs to go in the <head> section (anywhere between <head> and </head>).

Your code contains the css link after the head (</head>) tag, hence the errors you are getting.

Also, use 'code' and '/code' tags around perl scripts rather than 'php' tags. Your script should be something along these lines...

Code:
print "Content-type: text/html\n\n";

print "<html>\n <head>\n  <title>Results of Search</title>\n \n";

print "<link href=\"../beaver.css\" hreflang=\"en\" rel=\"stylesheet\" type=\"text/css\" charset=\"UTF-8\" ></head>\n";

print "<body bgcolor=\"WHITE\">\n <center>\n  <h1>Results of Search in $title</h1>\n </center>\n";

print "Below are the results of your Search in no particular order:<p><hr size=7 width=75%><p>\n";


Note the </head> tag after the css link.

Reply With Quote
  #5  
Old December 5th, 2003, 09:49 AM
Metatron Metatron is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 4 Metatron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for that ... like I say I'm new to both perl and this board. I did try that originally, but it wasn't split over two lines (i.e. the css link didn't have a print command before it) - does this make a difference?
If that is the definitive answer, I'll know that any further problem is likely to be syntax related ... is there anything like emacs for the windows o/s?

Reply With Quote
  #6  
Old December 5th, 2003, 09:55 AM
mlh2003's Avatar
mlh2003 mlh2003 is offline
Y? Y!?
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2003
Location: Brisbane, Australia
Posts: 1,571 mlh2003 User rank is Sergeant Major (2000 - 5000 Reputation Level)mlh2003 User rank is Sergeant Major (2000 - 5000 Reputation Level)mlh2003 User rank is Sergeant Major (2000 - 5000 Reputation Level)mlh2003 User rank is Sergeant Major (2000 - 5000 Reputation Level)mlh2003 User rank is Sergeant Major (2000 - 5000 Reputation Level)mlh2003 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 11 h 35 m 7 sec
Reputation Power: 43
Metatron - I'm not sure if you understood my last post.

The css link in your code was placed after the </head> tag, whereas it should be placed between the <head> and </head> tag.

NTEmacs and Crimson Editor are both OK for Windows. Do a Google search to find out about download options.

Reply With Quote
  #7  
Old December 5th, 2003, 10:05 AM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Sep 2001
Location: Dublin, Eire
Posts: 5,697 ishnid User rank is General 8th Grade (Above 100000 Reputation Level)ishnid User rank is General 8th Grade (Above 100000 Reputation Level)ishnid User rank is General 8th Grade (Above 100000 Reputation Level)ishnid User rank is General 8th Grade (Above 100000 Reputation Level)ishnid User rank is General 8th Grade (Above 100000 Reputation Level)ishnid User rank is General 8th Grade (Above 100000 Reputation Level)ishnid User rank is General 8th Grade (Above 100000 Reputation Level)ishnid User rank is General 8th Grade (Above 100000 Reputation Level)ishnid User rank is General 8th Grade (Above 100000 Reputation Level)ishnid User rank is General 8th Grade (Above 100000 Reputation Level)ishnid User rank is General 8th Grade (Above 100000 Reputation Level)ishnid User rank is General 8th Grade (Above 100000 Reputation Level)ishnid User rank is General 8th Grade (Above 100000 Reputation Level)ishnid User rank is General 8th Grade (Above 100000 Reputation Level)ishnid User rank is General 8th Grade (Above 100000 Reputation Level)ishnid User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 6 Days 21 h 31 m 9 sec
Reputation Power: 1507
The perl interpreter won't understand HTML so if you just type HTML code without a print statement, perl will try to execute it as Perl code and fail because it isn't valid.

Quote:
Originally posted by Metatron
is there anything like emacs for the windows o/s?

Not to be smart but there's an excellent program for Windows that's very similar to emacs. It's called emacs

See here in the FAQ on how to obtain it.

Reply With Quote
  #8  
Old December 5th, 2003, 10:33 AM
Metatron Metatron is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 4 Metatron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Heh ... my sister told me that emacs was for linux (another thing to get my head around) and that she didn't know of any authoring tools for windoze. And I believed her ... more fool me, eh?

Thanx for the help, I appreciate it.

Reply With Quote
  #9  
Old December 5th, 2003, 02:18 PM
icrf's Avatar
icrf icrf is offline
Perl Monkey
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: May 2003
Location: the far end of town where the Grickle-grass grows
Posts: 1,856 icrf User rank is Second Lieutenant (5000 - 10000 Reputation Level)icrf User rank is Second Lieutenant (5000 - 10000 Reputation Level)icrf User rank is Second Lieutenant (5000 - 10000 Reputation Level)icrf User rank is Second Lieutenant (5000 - 10000 Reputation Level)icrf User rank is Second Lieutenant (5000 - 10000 Reputation Level)icrf User rank is Second Lieutenant (5000 - 10000 Reputation Level)icrf User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 10 h 28 m 31 sec
Reputation Power: 103
Send a message via AIM to icrf
UltraEdit, EditPlus, and TextPad are probably the three most popular windows text/code editors (that I've heard of). The nature of open source means that there's generally a windows port of any popular linux app, so emacs/jed/vi/vim are all around if you look.

Also, you could use CGI.pm and generate more standard html (or go all the way up to HTML::Template).
Code:
use CGI qw/:standard/;

print header(),
      start_html( -title   => 'Results of Search',
                  -head    => Link( { -href     => '../beaver.css',
                                      -hreflang => 'en',
                                      -rel      => 'stylsheet',
                                      -type     => 'text/css',
                                      -charset  => 'UTF-8' } ),
                  -bgcolor => 'white'),
      h1( { -style => 'text-align: center' }, 'stuff'),
      'Below are the results of your Search in no particular order:',
      p( hr( { -size => '7', width => '75%' } ) );
__________________
Andrew - Perl (and VB.NET) Monkey

Never underestimate the bandwidth of a hatchback full of tapes.

Reply With Quote
  #10  
Old December 5th, 2003, 04:03 PM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,635 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 44 m 19 sec
Reputation Power: 77
Send a message via AIM to Hero Zzyzzx
Avoid relative paths ("../beaver.css") - what if you decide to move your script up or down the directory tree?

I personally cannot think of a reason to use relative paths over absolute. . .

Reply With Quote
  #11  
Old January 2nd, 2004, 02:36 PM
andyg1 andyg1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 215 andyg1 User rank is Corporal (100 - 500 Reputation Level)andyg1 User rank is Corporal (100 - 500 Reputation Level)andyg1 User rank is Corporal (100 - 500 Reputation Level)andyg1 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 3 h 2 m 40 sec
Reputation Power: 10
Hero ZzYzzx wrote:

Quote:
I personally cannot think of a reason to use relative paths over absolute. . .


I've come this problem. I use relative references. I test my webpages on a local server before uploading them. I would have to change every absolute reference to have it work... unless there's a way round it?

Andy
__________________
Time isn't wasted if you're wasted all the time

Reply With Quote
  #12  
Old January 2nd, 2004, 03:40 PM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,635 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 44 m 19 sec
Reputation Power: 77
Send a message via AIM to Hero Zzyzzx
Start a new thread. This is veering off topic.

Can you give more details? Are you talking paths relative to your webroot (that used by your webserver) or relative to your OS- those that are actually on the filesystem?

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > Linking an external CSS stylesheet to a Perl generated HTML document


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump