Skip to content

Commit

Permalink
Fixes #790: added visible for Nav and Dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark committed Aug 25, 2013
1 parent c835f17 commit 8a1bf04
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion framework/yii/bootstrap/Dropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Dropdown extends Widget
*
* - label: string, required, the label of the item link
* - url: string, optional, the url of the item link. Defaults to "#".
* - visible: boolean, optional, whether this menu item is visible. Defaults to true.
* - linkOptions: array, optional, the HTML attributes of the item link.
* - options: array, optional, the HTML attributes of the item.
*/
Expand Down Expand Up @@ -64,7 +65,11 @@ public function run()
protected function renderItems($items)
{
$lines = array();
foreach ($items as $item) {
foreach ($items as $i => $item) {
if (isset($item['visible']) && !$item['visible']) {
unset($items[$i]);
continue;
}
if (is_string($item)) {
$lines[] = $item;
continue;
Expand Down
7 changes: 6 additions & 1 deletion framework/yii/bootstrap/Nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Nav extends Widget
*
* - label: string, required, the nav item label.
* - url: optional, the item's URL. Defaults to "#".
* - visible: boolean, optional, whether this menu item is visible. Defaults to true.
* - linkOptions: array, optional, the HTML attributes of the item's link.
* - options: array, optional, the HTML attributes of the item container (LI).
* - active: boolean, optional, whether the item should be on active state or not.
Expand Down Expand Up @@ -123,7 +124,11 @@ public function run()
public function renderItems()
{
$items = array();
foreach ($this->items as $item) {
foreach ($this->items as $i => $item) {
if (isset($item['visible']) && !$item['visible']) {
unset($items[$i]);
continue;
}
$items[] = $this->renderItem($item);
}

Expand Down

0 comments on commit 8a1bf04

Please sign in to comment.