NAME
HTML::Template::Menu
SYNOPSIS
use HTML::Template::Menu;
my $m = new HTML::Template::Menu;
$m->add('/','home');
$m->add('/contact.html');
METHODS
new()
new menu
name()
returns name of the menu.
name_set()
sets name of menu, argument is string
add()
argument is url or runmode optional argument is label
If the first argument has no funny chars, it is treated as a runmode.
The label is what will appear in the link text If not provided, one will be made. If you have a runmode called see_more, the link text is "See More".
The link will be
<a href="?=$YOURRUNMODEPARAMNAME=$ARG1">$ARG2</a>
So in this example:
$m->add('view_tasks');
The result is:
<a href="?rm=view_tasks">View Tasks</a>
loop()
get loop suitable for HTML::Template object See SYNOPSIS.
count()
returns count of items in this menu
menu_class()
what the TMPL_VAR MAIN_MENU_CLASS will hold
menu_class_set()
arg is string sets the TMPL_VAR MAIN_MENU_CLASS
output()
If you just want the output with the default hard coded template. The default template code is stored in:
$CGI::Application::Plugin::MenuObject::DEFAULT_TMPL
ADDING MENU ITEMS
my $m = $self->menu_get('main menu');
$m->add('home');
$m->add('http://helpme.com','Need help?');
$m->add('logout');
Elements for the menu are shown in the order they are inserted.
DEFAULT TEMPLATE
You may want to change this.
<div class="<TMPL_VAR MAIN_MENU_CLASS>"><p>
<TMPL_LOOP MAIN_MENU_LOOP><nobr><b><a href="<TMPL_VAR URL>">[<TMPL_VAR LABEL>]</a></b></nobr>
</TMPL_LOOP></p></div>
One way to change it:
$HTML::Template::Menu::DEFAULT_TMPL = q{
<div class="<TMPL_VAR MAIN_MENU_CLASS>"><p>
<TMPL_LOOP MAIN_MENU_LOOP><nobr><b><img src="/gfx/bullet.png"> <a href="<TMPL_VAR URL>">[<TMPL_VAR LABEL>]</a></b></nobr>
</TMPL_LOOP></p></div>
};
Or you can just get the menu loop and inject into your template
my $menu_loop = $m->_get_main_menu_loop;
AUTHOR
Leo CHarre leocharre at cpan dot org
SEE ALSO
CGI::Application::Plugin::Menu