navbarMenu.vm
1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#macro( displayNavbarMenu $menu $count)
#if ($displayer.isAllowed($menu))
#set ($count = $count + 1)
## set menu title
#set ($title = $displayer.getMessage($menu.title))
#if (!$menu.url) #set ($url="javascript:void(0)") #else #set ($url=$menu.url) #end
## create a single menu item
#if ($menu.components.size() == 0)
<li class="#if ($menu.name == $currentMenu)active#end">
<a href="$url" title="$title" #if($menu.target)target="$menu.target" #end#if($menu.width)style="width: ${menu.width}px"#end>${title}</a>
#else ## create multiple menu items in a menu
#if ($menu.components.size() > 0)
#set ($hasViewableChildren = false)
#set ($renderedChildren = 0)
#foreach ($menuIt in $menu.components)
#if ($displayer.isAllowed($menuIt))
#set($hasViewableChildren = true)
#set($renderedChildren = $renderedChildren + 1)
#end
#end
#end
<li#if ($hasViewableChildren) class="dropdown#if ($menu.name == $currentMenu) active#end"#end>
<a href="#" title="$title"
#if($menu.target)target="$menu.target" #end
#if($menu.width)style="width: ${menu.width}px"#end
class="dropdown-toggle" data-toggle="dropdown">${title}</a>
#end
#if ($menu.components.size() > 0)
#if ($hasViewableChildren)
<ul class="dropdown-menu">
#end
#set ($count = 0)
#foreach ($menuIt in $menu.components)
#displayNavbarMenu($menuIt, $count)
#end
#if ($hasViewableChildren && ($count == $renderedChildren))
</li>
#else
</ul>
#if ($count > $renderedChildren)
</li>
#end
#end
#else
</li>
#if ($menu.parent && $count == $menu.parent.components.size())
</ul>
#end
#end
#end
#end
#displayNavbarMenu($menu, 0)