Nicholas Bamber


CGI::Application::Plugin::PageLookup::Menu - Support for consistent menus across a multilingual website


Version 1.8


The CGI::Application::Plugin::PageLookup::Loop module can be used to create a database driven menu and similarly data driven site map page. However the Loop module can only translate into other languages if the URLs are kept the same apart from a language identifier. This means that the website would have search engine friendly in only one language. The CGI::Application::Plugin::PageLookup::Href module could be used to create a static menu and site map that is automatically translated into various languages with search engine friendly URLs. However they cannot be combined as you cannot pass through first the Loop and then the Href. What this module offers is a specialised variant of the Loop smart object that does combine these features. This module depends on CGI::Application::Plugin::PageLookup.


In the template you might define a menu as follows (with some CSS and javascript to make it look nice):

    <TMPL_LOOP NAME="menu.structure('title')">
                <a href="<TMPL_VAR NAME="this.pageid">"><TMPL_VAR NAME="this.title"></a>
                <TMPL_IF NAME="this.structure('title')">
                <TMPL_LOOP NAME="this.structure('title')">
                                <a href="/<TMPL_VAR NAME="this.pageid">"><TMPL_VAR NAME="this.title"></a>
                                <TMPL_IF NAME="this.structure('title')">
                                <TMPL_LOOP NAME="this.structure('title')">
                                        <a href="/<TMPL_VAR NAME="this.pageid">"><TMPL_VAR NAME="this.title"></a>

and the intention is that this should be the same on all English pages, the same on all Vietnamese pages etc etc. You must register the "menu" parameter as a CGI::Application::Plugin::PageLookup::Menu object as follows:

    use CGI::Application;
    use CGI::Application::Plugin::PageLookup qw(:all);
    use CGI::Application::Plugin::PageLookup::Menu;
    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
                        menu => 'CGI::Application::Plugin::PageLookup::Menu',



  • This module requires no extra table but it does depend on the 'lineage' and 'rank' columns in the cgiapp_strcuture table. These columns work the same way as they do in the cgiapp_loops table. That is the items are ordered according to the rank column and the lineage column is a comma separated list indicating the ranks of the parent menu items.

  • The module can be used to get data either for menus or human readable sitemaps.

  • One value that will always be returned is the 'pageId' column which can be translated into a URL as dictated by the website policy. However due to capitalisation issues, you must either call it 'pageid' in the template or specify 'case_sensitive => 1' somewhere in the template infrastructure.

  • Use of this module for creating menus and sitemaps rather than the Loop module also means you may not need to set 'globalvars => 1' in the template infrastructure.

  • You can specify additional columns from the cgiapp_pages table to be included the parameters. These could include a title, may be some javascript etc. These columns are not specified in the core database spec.

  • In the synopsis all parameters below the headline structure call were shown as being "this dot something". In accordance with HTML::Template::Plugin::Dot this can be changed by using ":" notation. This has not actually been tested yet. Nor have we tried testing varying the arguments at different levels of the menu structure.



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


This function is specified in the template where additional columns are specified. If no arguments are specified only the 'pageId' column is returned for each menu item. Additional arguments should be specified either as a single comma separated string (deprecated) or as multiple arguments.


A private function that does what is says.


This function is a variant of the structure function, which allows one to specify a part of the menu. The first argument is the database lineage which is a string consisting of comma separated numbers. The other arguments are as described under structure. The slice function can only be used in the topmost TMPL_LOOP of a template.


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.


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

    perldoc CGI::Application::Plugin::PageLookup::Menu

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.