if ($menu_item->{submenu} || !defined($menu_item->{module}) || ($menu_item->{module} eq "menu.pl")) {
$item->{subitems} = [];
+ $item->{image} = _icon_path("$name.png");
create_menu($menu, $item->{subitems}, "${parent}${name}", $depth * 1 + 1);
} else {
+ $item->{image} = _icon_path("${parent}${name}.png");
$menu->menuitem_new("${parent}${name}", $item);
}
}
}
+
+sub _icon_path {
+ my ($label, $size) = @_;
+
+ $size ||= 16;
+
+ return "image/icons/${size}x${size}/$label";
+}
+
<ul id="main_menu_model">
[%- FOREACH mainitem = menu_items %]
[%- SET main_id = main_id + 1 %]
- <li id="[% main_id %]">
+ <li id="[% main_id %]"[% IF mainitem.image %] itemIcon="[% mainitem.image %]"[% END %]>
<a href="[% IF mainitem.href %][% mainitem.href %][% ELSE %]#[% END %]"[% IF mainitem.target %] target="[% mainitem.target %]"[% END %]>
[%- HTML.escape(mainitem.title) %]
</a>
[%- SET sub1_id = main_id * 100 %]
[%- FOREACH sub1item = mainitem.subitems %]
[%- SET sub1_id = sub1_id + 1 %]
- <li id="[% sub1_id %]">
+ <li id="[% sub1_id %]"[% IF sub1item.image %] itemIcon="[% sub1item.image %]"[% END %]>
<a href="[% IF sub1item.href %][% sub1item.href %][% ELSE %]#[% END %]"[% IF sub1item.target %] target="[% sub1item.target %]"[% END %]>
[%- HTML.escape(sub1item.title) %]
</a>
[%- SET sub2_id = sub1_id * 100 %]
[%- FOREACH sub2item = sub1item.subitems %]
[%- SET sub2_id = sub2_id + 1 %]
- <li id="[% sub2_id %]">
+ <li id="[% sub2_id %]"[% IF sub2item.image %] itemIcon="[% sub2item.image %]"[% END %]>
<a href="[% IF sub2item.href %][% sub2item.href %][% ELSE %]#[% END %]"[% IF sub2item.target %] target="[% sub2item.target %]"[% END %]>
[%- HTML.escape(sub2item.title) %]
</a>