View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Nicholas Bamber > CGI-Application-Plugin-PageLookup-1.8 > CGI::Application::Plugin::PageLookup::Value



Annotate this POD


New  3
Open  2
View/Report Bugs
Module Version: 1.8   Source  


CGI::Application::Plugin::PageLookup::Value - Manage values scattered across a website


Version 1.8


This module allows the management of template variable instantiation across a website. You can specialise a default value for a parameter (without requiring it to be used on every page) and override that value for specific pages. Or you can merely set the value for individual pages. This depends on CGI::Application::Plugin::PageLookup. For loops see CGI::Application::Plugin::PageLookup::Loop.


In the template you can do things like <TMPL_VAR NAME="values.hope">, <TMPL_VAR NAME=""> and <TMPL_VAR NAME="">. You must register the "values" parameter as a CGI::Application::Plugin::PageLookup::Value object as follows:

    use CGI::Application;
    use CGI::Application::Plugin::PageLookup qw(:all);
    use CGI::Application::Plugin::PageLookup::Value;
    use HTML::Template::Pluggable;
    use HTML::Template::Plugin::Dot;

    sub cgiapp_init {
        my $self = shift;

        # pagelookup depends CGI::Application::DBH;
        $self->dbh_config(......); # whatever arguments are appropriate



                # load smart dot-notation objects
                objects =>
                        # Register the 'values' parameter
                        values => 'CGI::Application::Plugin::PageLookup::Value,


After that all that remains is to populate the cgiapp_values table with the appropriate values. Notice that the code does not need to know what comes after the dot in the templates. So if you want to set "values.hope" to "disappointment" in all English pages you would run

        INSERT INTO cgiapp_values (lang, param, value) VALUES ('en', 'hope', 'disappointment')

On the other hand if you wanted set "values.hope" to "a glimmer of light" on page 7 but "disappointment" everywhere else, then you would run

        INSERT INTO cgiapp_values (lang, param, value) VALUES ('en', 'hope', 'disappointment')
        INSERT INTO cgiapp_values (lang, internalId, param, value) VALUES ('en', 7, 'hope', 'a glimmer of light')


This module depends on only one extra table: cgiapp_values. The lang and internalId columns join against the cgiapp_table. However the internalId column can null, making the parameter available to all pages in the same language. The lang, internalId and param columns form the key of the table.

Table: cgiapp_values
 Field         Type                                                                Null Key  Default Extra 
 ------------  ------------------------------------------------------------------- ---- ---- ------- -----
 lang          varchar(2)                                                          NO   UNI  NULL          
 internalId    unsigned numeric(10,0)                                              YES  UNI  NULL          
 param         varchar(20)                                                         NO   UNI  NULL          
 value         text                                                                NO        NULL          



A constructor following the requirements set out in CGI::Application::Plugin::PageLookup.


We need to autoload methods so that the template writer can use variables without needing to know where the variables will be used. Thus 'can' must return a true value in all cases to avoid breaking HTML::Template::Plugin::Dot. Also 'can' is supposed to either return undef or a CODE ref. This seems the cleanest way of meeting all requirements.


We need to autoload methods so that the template writer can use variables without needing to know where the variables will be used.


We have to define DESTROY, because an autoloaded version would be bad.


Nicholas Bamber, <nicholas at>


Please report any bugs or feature requests to bug-cgi-application-plugin-pagelookup at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


AUTOLOAD is quite a fraught subject. There is probably no perfect solution. See for a sample of the issues.


You can find documentation for this module with the perldoc command.

    perldoc CGI::Application::Plugin::PageLookup::Value

You can also look for information at:



Copyright 2009 Nicholas Bamber.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.

syntax highlighting: