Skip to content

Commit 26419eb

Browse files
Merge pull request #24 from nusakan/master
create a menu which combined simple item and dropdown menu.
2 parents d05e00a + 0f8ebb9 commit 26419eb

File tree

1 file changed

+41
-19
lines changed
  • modules/sfTwitterBootstrap/templates

1 file changed

+41
-19
lines changed
+41-19
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,61 @@
11
<?php
2-
use_helper('I18N');
3-
/** @var Array of menu items */ $items = $sf_data->getRaw('items');
4-
/** @var Array of categories, each containing an array of menu items and settings */ $categories = $sf_data->getRaw('categories');
2+
use_helper('I18N');
3+
/** @var Array of menu items */ $items = $sf_data->getRaw('items');
4+
/** @var Array of categories, each containing an array of menu items and settings */ $categories = $sf_data->getRaw('categories');
55
?>
66

77

88
<?php if (count($items)): ?>
99
<ul class="nav">
1010
<?php if (sfTwitterBootstrap::hasItemsMenu($items)): ?>
11-
<li class="dropdown" data-dropdown="dropdown"><a href="#" class="dropdown-toggle" >Menu</a>
12-
<ul class="dropdown-menu">
13-
<?php include_partial('sfTwitterBootstrap/menu_list', array('items' => $items, 'items_in_menu' => true)); ?>
14-
</ul>
15-
</li>
16-
<?php endif; ?>
11+
<li class="dropdown" data-dropdown="dropdown"><a href="#" class="dropdown-toggle" >Menu</a>
12+
<ul class="dropdown-menu">
13+
<?php include_partial('sfTwitterBootstrap/menu_list', array('items' => $items, 'items_in_menu' => true)); ?>
14+
</ul>
15+
</li>
16+
<?php endif; ?>
1717
<?php include_partial('sfTwitterBootstrap/menu_list', array('items' => $items, 'items_in_menu' => false)); ?>
1818
</ul>
1919
<?php endif; ?>
20+
2021
<?php if (count($categories)): ?>
2122
<ul class="nav">
23+
2224
<?php foreach ($categories as $name => $category): ?>
23-
<?php if (sfTwitterBootstrap::hasPermission($category, $sf_user)): ?>
24-
<?php if (sfTwitterBootstrap::hasItemsMenu($category['items'])): ?>
25-
<li class="dropdown"><a href="#" class="dropdown-toggle" ><?php echo __(isset($category['name']) ? $category['name'] : $name) ?></a>
26-
<ul class="dropdown-menu">
27-
<?php include_partial('sfTwitterBootstrap/menu_list', array('items' => $category['items'], 'items_in_menu' => true)) ?>
28-
</ul>
29-
</li>
30-
<?php endif; ?>
31-
<?php endif; ?>
25+
<?php if (sfTwitterBootstrap::hasPermission($category, $sf_user)): ?>
26+
<li class="dropdown">
27+
28+
<?php if (isset($category['url'])): ?>
29+
30+
<?php $class = ''; ?>
31+
<?php if (isset($category['items'])): ?>
32+
<?php if (sfTwitterBootstrap::hasItemsMenu($category['items'])): ?>
33+
<?php $class = 'dropdown-toggle'; ?>
34+
<?php endif; ?>
35+
<?php endif; ?>
36+
37+
<a href="<?php echo url_for($category['url']); ?>" class="<?php echo $class; ?>" ><?php echo __(isset($category['name']) ? $category['name'] : $name) ?></a>
38+
39+
<?php else: ?>
40+
<a href="#" class="dropdown-toggle" ><?php echo __(isset($category['name']) ? $category['name'] : $name) ?></a>
41+
<?php endif; ?>
42+
43+
<?php if (isset($category['items']) && sfTwitterBootstrap::hasItemsMenu($category['items'])): ?>
44+
<ul class="dropdown-menu">
45+
<?php include_partial('sfTwitterBootstrap/menu_list', array('items' => $category['items'], 'items_in_menu' => true)) ?>
46+
</ul>
47+
<?php endif; ?>
48+
</li>
49+
<?php endif; ?>
3250
<?php endforeach; ?>
51+
3352
<?php foreach ($categories as $name => $category): ?>
53+
<?php if (isset($category['items'])): ?>
3454
<?php include_partial('sfTwitterBootstrap/menu_list', array('items' => $category['items'], 'items_in_menu' => false)) ?>
55+
<?php endif; ?>
3556
<?php endforeach; ?>
57+
3658
</ul>
3759
<?php elseif (!count($items)): ?>
3860
<?php echo __('sfTwitterBootstrap is not configured.'); ?>
39-
<?php endif; ?>
61+
<?php endif; ?>

0 commit comments

Comments
 (0)