NAME
CatalystX::Menu::Suckerfish - Generate an HTML UL element for use as a CSS-enhanced Suckerfish menu.
SYNOPSIS
package MyApp::Controller::Whatever;
sub someaction :Local
:MenuPath('Electronics/Computers')
:MenuTitle('Computers')
{ ... }
sub begin :Private {
my ($self, $c) = @_;
my $menu = CatalystX::Menu::Suckerfish->new(
context => $c,
ul_id => 'navmenu', # <ul id="navmenu"> ... </ul>
ul_class => 'sf-menu', # <ul id="navmenu" class="sf-menu"> ... </ul>
text_container => { # wrap plain text nodes in this HTML element
element => 'span', # so that styles can be applied if desired.
attrs => {
class => 'myspan',
},
},
top_order => [qw(Home * About)], # Put Home and About on the ends,
# everything else in-between
filter => sub { # Filter out actions we don't want in menu
my ($c, %actions) = @_;
return
map {$_, $actions{$_}}
grep {$actions{$_}->can_visit($c)}
grep {UNIVERSAL::isa($actions{$_}, 'Catalyst::Action::Role::ACL')}
keys %actions;
},
);
$c->session->{navmenu} = $menu->output;
# include the UL element in your Template: [% c.session.navmenu %]
}
# include any desired styles (CSS) for the UL element in your markup
DESCRIPTION
Builds nested HTML UL element with links to your Catalyst application's public actions for use as a Suckerfish or Superfish menu.
Suckerfish menus: http://www.alistapart.com/articles/dropdowns Superfish jQuery menu plugin: http://users.tpg.com.au/j_birch/plugins/superfish/
METHODS
new( $tree, %params )
Takes a menu tree produced by Catalyst::Controller::Menutree (CatalystX::MenuTree) and a list of key/value parameter pairs.
Params
- ul_id
-
The ID attribute to be applied to the outer HTML UL element.
- ul_class
-
The class attribute to be applied to the outer HTML UL element.
- text_container
-
Specifies an HTML element (typically a SPAN) in which to enclose menu items which don't include A elements. This makes it possible to apply similar styles to both plain text and A elements for consistent appearance.
- top_order
-
A list of top level menu item labels. Menu items are sorted alphabetically by default. top_order allows you to specify the order of one or more items. The asterisk (*) inserts any menu items not listed in top_order.
output
Return HTML UL markup.
INTERNAL METHODS
_get_top_level_order()
Return hash keys for top level menu items. Order is determined by the top_order param. Items not explicitly referenced in the top_order param are sorted lexically and inserted where the asterisk (*) appears in the top_order param string.
_gen_menu($self, $h, $tree)
Recursively construct a (possibly) nested HTML UL element.
$h is an HTML::Element object. $tree is a node in the tree created in the parent class.
AUTHOR
David P.C. Wollmann <converter42@gmail.com>
BUGS
This is brand new code, so use at your own risk.
COPYRIGHT & LICENSE
Copyright 2009 by David P.C. Wollmann
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.