NAME
CGI::Application::Plugin::PageLookup::Href - Manage internal URLs
VERSION
Version 1.8
DESCRIPTION
This module manages the instantiation of list style template parameters across a website; for example TMPL_LOOP in HTML::Template, though one must use HTML::Template::Pluggable for it to work. For example a menu is typically implemented in HTML as <ul>....</ul>. Using this module the menu can be instantiated from the database and the same data used to instantiate a human-readable sitemap page. On the other hand the staff page will have list data that is only required on that page. This module depends on CGI::Application::Plugin::PageLookup.
SYNOPSIS
In the template you might define a number of links as follows:
<p>This page in other languages:</p>
<ul>
<li><a href="<TMPL_VAR NAME="href.translate('en')">">English</a></li>
<li><a href="<TMPL_VAR NAME="href.translate('de')">">German</a></li>
<li><a href="<TMPL_VAR NAME="href.translate('fr')">">French</a></li>
</ul>
<p>Some other pages that may be of interest</p>
<ul>
<li><a href="<TMPL_VAR NAME="href.refer(1)">">My first page</a></li>
<li><a href="<TMPL_VAR NAME="href.refer(2)">">My second and more exciting page</a></li>
<li><a href="<TMPL_VAR NAME="href.refer(3)">">My last will and testament</a></li>
</ul>
You must register the "href" parameter as a CGI::Application::Plugin::PageLookup::Href object as follows:
use CGI::Application;
use CGI::Application::Plugin::PageLookup qw(:all);
use CGI::Application::Plugin::PageLookup::Href;
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 'href' parameter
href => 'CGI::Application::Plugin::PageLookup::Href',
},
);
}
...
FUNCTIONS
new
A constructor following the requirements set out in CGI::Application::Plugin::PageLookup.
translate
This function takes the existing page id and translates it into another specified language. This way every page can link to its cognate page in another languages.
refer
This function takes an internal id and translated that into the corresponding page but in the same language as the current page. This way URLs can be search engine friendly irrespective of language.
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::Href
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=CGI-Application-Plugin-PageLookup
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
http://cpanratings.perl.org/d/CGI-Application-Plugin-PageLookup
Search CPAN
http://search.cpan.org/dist/CGI-Application-Plugin-PageLookup/
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.