|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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:
... 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. |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
Thanks for your reply. Y'know I actually think that I tried that, kinda like this ...
PHP Code:
... 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? |
|
#4
|
||||
|
||||
|
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. |
|
#5
|
|||
|
|||
|
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? |
|
#6
|
||||
|
||||
|
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. |
|
#7
|
||||
|
||||
|
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:
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.
__________________
~ishnid; Have you tried: [ search.cpan.org | perldoc | Java API | mysql.com | google ] Apostrophes are NOT used for possessive pronouns or for noun plurals, including acronyms. |
|
#8
|
|||
|
|||
|
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. |
|
#9
|
||||
|
||||
|
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. |
|
#10
|
||||
|
||||
|
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. . . |
|
#11
|
|||
|
|||
|
Hero ZzYzzx wrote:
Quote:
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 |
|
#12
|
||||
|
||||
|
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? |
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > Linking an external CSS stylesheet to a Perl generated HTML document |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|