Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 01330ec25d
Fetching contributors…

Cannot retrieve contributors at this time

94 lines (82 sloc) 3.009 kb
__NAME__ purpose
specify actions to be executed automatically at the beginning of every page access
__NAME__ see also
Preload, AutoEnd
__NAME__ synopsis
<arg choice='plain' rep='repeat'><replaceable>subroutine_name_or_ITL_code</replaceable></arg>
__NAME__ description
Specify actions (in form of &PERL; subroutines or &glos-ITL; tags)
that are to be invoked automatically, on every
page access. This step is performed before any page parsing occurs,
and before the action or page is even determined.
The directive can be set to the name of a subroutine (&conf-Sub; or
&conf-GlobalSub;), or to a string containing &glos-ITL; tags.
The return value from the code run is discarded.
__NAME__ notes
__NAME__ example: Simple Autoload example
Put the following in &gcf;:
GlobalSub <<EOR
sub simple_gsub {
open OUT, "> /tmp/out";
print OUT scalar localtime, "\n";
close OUT;
Put the following in &ccf;:
Autoload simple_gsub
Now, at each page visit, the file <filename>/tmp/out</filename> will
contain the access time. This example is pretty useless and does not
convey good programming practice (the file opening part), but it does
show a practical, stand-alone example.
__NAME__ example: Redirect page accesses
Let's say that a new page visit is "triggered" as a result of users
submitting a &glos-HTML; form. At that point, <mv>mv_nextpage</mv>
contains the name of the page to display next, of course.
The following would redirect all accesses from
directory <filename class='directory'>public/</filename> to
directory <filename class='directory'>private/</filename>:
Autoload [perl] $CGI->{mv_nextpage} =~ s:^public/:private/:; [/perl]
__NAME__ example: Temporary change of configuration directives
As you might know, on each page access, all catalog
&glos-configuration; directives (global and catalog) are "re-instantiated",
and valid for the current page. This particularly convenient feature
allows us to change (modify, add or delete) configuration directives
as we see fit on a per-page basis,
without worrying about them being persistent, and consequently,
even without the need to re-set them back to original values.
The following example (put in &ccf;) displays a different flypage for
Opera web browsers:
Autoload <<EOA
if ($Session->{browser} =~ /opera/i) {
$Config->{Special}->{flypage} = 'opera_flypage';
<!-- (Remark irrelevant in the context)
Please note that &conf-SpecialPage; is the corresponding directive in
the catalog &glos-configuration; (and not <literal>Special</literal> as
we see above). This is an exceptional case &mdash; the hash keys otherwise
have the same name as the catalog configuration directives themselves.
Jump to Line
Something went wrong with that request. Please try again.