Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

CGI header

by Anonymous Monk
on Oct 28, 2004 at 02:38 UTC ( #403230=perlquestion: print w/replies, xml ) Need Help??

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

How do you create a cgi header that will appear on all pages. I am wanting to create a script that will be run on every page at the very top. Similar to how ColdFusion uses their application script. I am currently using a two frames. One contains a menu at the top, the other the relative information below. If user drags a button (ie image) from top frame to bottom, the page loads fullscreen with no frames (the menu dissappears). Thanks people.

Replies are listed 'Best First'.
Re: CGI header
by talexb (Canon) on Oct 28, 2004 at 03:35 UTC

    I'm not sure whether you're confused about the terms you're using.

    A CGI header isn't really something that exists .. there's an HTTP header which icnludes things like information about the cookie updates, and there's also whatever appears at the top of the web page, sy, a menu or something like that.

    If you're talking about the first kind, then your CGI should be able to control what HTTP headers go out -- usually you're using the venerable CGI or something more advanced like CGI::Application so that you don't have to get your hands dirty actually sending out those kinds of headers yourself.

    If you're talking about some kind of menu at the top of your page, then a templaet is probably what you're looking for .. I can highly recommend Template::Toolkit (and for the dyslexics in the audience, that's not Toolkit::Template) (see also the web site).

    Think about those two options and see if you can give us more information on what you're looknig for. it's difficult to answer correctly if the question is not clear.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re: CGI header
by csuhockey3 (Curate) on Oct 28, 2004 at 06:29 UTC
    I might be misunderstanding the question, but I believe I did something similar to what you might need a long time ago. I put all of my header code in to a separate file and called it when needed throughout my CGI.(multiple pages, forms, error pages, confirmation page ...) it acted more like a bread crumbing, but maybe this is what you are looking for? I second the use of Template::Toolkit, but this was writen before I was comforatble with it, and can an alernative if you are limited to what you can use.
    My 'header' displayHeader.pl:
    sub displayHeader{ print <<DISPLAYINGHEADER; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!-- continue all of the junk you want to include in each page --> DISPLAYINGHEADER }

    From there, my CGI required the displayHeader file and called it like so:
    sub displayErrorPage{ &displayHeader; ... } sub displayConfirmationPage{ &displayHeader; print $cgi->p("Thank You"); ... }
    The two functions above are entered based on the return value of a form validation subroutine (error checking form input).
Re: CGI header
by BUU (Prior) on Oct 28, 2004 at 03:18 UTC
    You can't via CGI. Your best bet is to configure the webserver to always run some script before every other script, or something similar. For example, using apache and mod_perl, it is possible to configure a script that runs after every request and gets the full content that would be sent back to the request.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2021-03-04 00:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (97 votes). Check out past polls.

    Notices?