Hello all. I'm trying to develop a generic menu system for our various
web apps. My basic idea is to create a nested array of hashes, one
array for each sub-level. I can't really see this going beyond 3 levels
deep.
Here's what I have so far. The key "action" corresponds to the
CGI::Application run-mode. Any given hashref would only have one
"sub_menu" key.
Usage:
my ($menu, $sub_menu) = &menu('action');
This way, the menu array can be separate from the sub-menu array.
Obviously I'm still thinking this through, but this is what I came up
with in about 20 minutes :)
It looks like &menu needs as many arguments as the sub-level you're
trying to reach. Probably not the best way to build a system.
What do you guys (and gals) do?
sub menu {
my $action = shift;
my $menu = [
{action => 'action1',
title => 'Title1',
sub_menu => [{action => 'action1a',
title => 'Title 1a'},
{action => 'action1b',
title => 'Title 1b'}]
},
{action => 'action2',
title => 'Title 2',
sub_menu => [{action => 'action2a',
title => 'Title 2a'},
{action => 'action2b',
title => 'Title 2b'}]
}
];
my (@m1, $sub);
foreach my $m (@{$menu}){
my %tmp = %{$m};
delete $tmp{sub_menu};
push(@m1, \%tmp);
$sub = $m->{sub_menu} if $m->{action} eq $action;
}
return (suppressed, $sub);
}
Joel Gwynn
Variable Data
Spire
617 832-1957
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.