Now, if a submenu is empty, it will not be rendered
This commit is contained in:
@@ -16,4 +16,8 @@ $sidebar->create_submenu('administrativo', 'Administrativo');
|
||||
|
||||
$sidebar->add_on_new('basico', '', 'Geografico', '', Array(), -1);
|
||||
|
||||
$sidebar->create_submenu('teste', 'Teste');
|
||||
//$sidebar->add_on_new('teste', '', 'Elemento');
|
||||
|
||||
|
||||
echo $sidebar->render();
|
||||
@@ -67,6 +67,7 @@ class MenuItem {
|
||||
$this->link = $link;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the menu item name.
|
||||
*
|
||||
@@ -77,6 +78,7 @@ class MenuItem {
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the menu item title.
|
||||
*
|
||||
@@ -136,7 +138,12 @@ class MenuItem {
|
||||
* @return string
|
||||
*/
|
||||
public function render() {
|
||||
return '<li>' . $this->html->link($this->link, $this->title, $this->icon, $this->attributes) . $this->renderNestedMenu() . '</li>';
|
||||
if( empty($this->nested) ){
|
||||
return '<li>' . $this->html->link($this->link, $this->title, $this->icon, $this->attributes) . '</li>';
|
||||
}
|
||||
if ( !empty($this->nested->items()) ) {
|
||||
return '<li>' . $this->html->link($this->link, $this->title, $this->icon, $this->attributes) . $this->renderNestedMenu() . '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user