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->add_on_new('basico', '', 'Geografico', '', Array(), -1);
|
||||||
|
|
||||||
|
$sidebar->create_submenu('teste', 'Teste');
|
||||||
|
//$sidebar->add_on_new('teste', '', 'Elemento');
|
||||||
|
|
||||||
|
|
||||||
echo $sidebar->render();
|
echo $sidebar->render();
|
||||||
@@ -67,6 +67,7 @@ class MenuItem {
|
|||||||
$this->link = $link;
|
$this->link = $link;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the menu item name.
|
* Set the menu item name.
|
||||||
*
|
*
|
||||||
@@ -77,6 +78,7 @@ class MenuItem {
|
|||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the menu item title.
|
* Set the menu item title.
|
||||||
*
|
*
|
||||||
@@ -136,7 +138,12 @@ class MenuItem {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function render() {
|
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