WTF::Pages - Parent class for WTF web page modules


This document describes WTF::Pages version 1.02


        # for use within page generation subclasses
        package WTF::Pages::Input;
        use strict;
        use warnings;
        use base 'WTF::Pages';
        sub screen_input {
                my $tmpl_obj = $self->setup_tmpl('input.tmpl');
                $tmpl_obj->param( 'title' => TITLE );
                return $tmpl_obj->output();
        # for use within WTF::Apache::Response
        use WTF::Pages;
        sub handler {
                my ($r) = @_;
                print WTF::Pages::dispatch($r);
                return Apache2::Const::OK;


This module is the parent class for WTF web page container modules. It provides these subclasses the important and frequently used ``setup_tmpl'' method. It also handles page dispatching called from WTF::Apache::Response through the ``dispatch'' function and the ``DISPATCH_TABLE'' constant.

This module sets up a ``DISPATCH_TABLE'' constant that must be edited when adding, removing, or moving pages. The table is an anonymous hash with keys being partial URLs and values being references to arrays containing two elements. The first element is a page subclass module name, and the second is a method within that subclass what should handle the page generation.

As a simple example, ``DISPATCH_TABLE'' might look similar to this:

        DISPATCH_TABLE => {
                '/somepage' => [ 'Subclass', 'screen_somepage' ],

In this example, ``/input'' is the end of a URL that should get picked up by the dispatcher. Requests with URLs that match ``/input'' will be dispatched to ``WTF::Pages::Subclass->screen_somepage()''. An example URL might be:

In this example, ``'' is the ``ROOT_URL''.


This parent class offers a method to be called by subclasses and a function to be called by WTF::Apache::Response.


This function is only called from WTF::Apache::Response to pass an incoming request off to the appropriate subclass page generation method. This function requires an Apache request (Apache2::RequestRec) object.

        my $html = WTF::Pages::dispatch($r);

If everything goes according to plan, this function should return HTML ready for display.


This method is designed to be called from page generation subclasses to get an HTML::Template object pre-setup with WTF framework defaults. The method accepts a single input, a string representing the HTML::Template template file name (relative to the template directory set in WTF::Config).

        # ...from WTF::Pages::Input, which inherrits from WTF::Pages
        sub screen_input {
                my $tmpl_obj = $self->setup_tmpl('input.tmpl');
                $tmpl_obj->param( 'title' => TITLE );
                return $tmpl_obj->output();

In the above example, ``$tmpl_obj'' is an HTML::Template object with appropriate WTF framework defaults set.


WTF::Pages depends on the following modules:


Use of this module implies the reading and agreement with the license under which this software is release. That license can be found in the ``license.txt'' file included with this distribution.