Nicholas Bamber > CGI-Application-Plugin-PageLookup > CGI::Application::Plugin::PageLookup::Menu

Download:
CGI-Application-Plugin-PageLookup-1.8.tar.gz

Dependencies

Annotate this POD

CPAN RT

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

NAME ^

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

VERSION ^

Version 1.8

DESCRIPTION ^

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.

SYNOPSIS ^

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

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

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

        $self->html_tmpl_class('HTML::Template::Pluggable');

        $self->pagelookup_config(

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

        );
    }

NOTES ^

FUNCTIONS ^

new

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

structure

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.

__populate_lower_loops

A private function that does what is says.

slice

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.

AUTHOR ^

Nicholas Bamber, <nicholas at periapt.co.uk>

BUGS ^

Please report any bugs or feature requests to bug-cgi-application-plugin-pagelookup at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CGI-Application-Plugin-PageLookup. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT ^

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

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

You can also look for information at:

ACKNOWLEDGEMENTS ^

COPYRIGHT & LICENSE ^

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 http://dev.perl.org/licenses/ for more information.

syntax highlighting: