From: Vincent Vanwaelscappel Date: Wed, 10 Jul 2019 18:21:43 +0000 (+0200) Subject: #2878 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=bbf025d02159b3fadfed0b634f29cf9f8fd2db4f;p=cubist_cms-back.git #2878 --- diff --git a/src/app/Magic/Menu/Item.php b/src/app/Magic/Menu/Item.php index 6ba8316..db2e6af 100644 --- a/src/app/Magic/Menu/Item.php +++ b/src/app/Magic/Menu/Item.php @@ -41,6 +41,12 @@ class Item */ protected $_classes = []; + + /** + * @var string + */ + protected $_type = ''; + /** * @param string $id */ @@ -81,6 +87,22 @@ class Item $this->addChild($child); } + /** + * @return string + */ + public function getType(): string + { + return $this->_type; + } + + /** + * @param string $type + */ + public function setType(string $type): void + { + $this->_type = $type; + } + /** * @return mixed */ @@ -132,7 +154,7 @@ class Item /** * @return string */ - public function getTitle(): string + public function getTitle() { return $this->_title; } @@ -140,7 +162,7 @@ class Item /** * @param string $title */ - public function setTitle(string $title): void + public function setTitle($title) { $this->_title = $title; } @@ -209,15 +231,26 @@ class Item // Handle items with submenus if ($child->hasChildren()) { // Create an empty sub-element that will serve as a wrapper for the submenu(s) - $wrapper = $parent->raw('')->attr(['class' => 'nav-submenu-wrapper']); + + + if ($child->getType() == 'mega') { + foreach ($child->getChildren() as $submenu) { + $wrapper = $parent->raw('')->attr(['class' => 'nav-submenu-wrapper']); + $wrapper->raw($submenu->getTitle())->attr(['class' => 'nav-submenu-title']); + foreach ($submenu->getChildren() as $subitem) { + $wrapper->add($subitem->getTitle(), $subitem->getHref()); + } + } + } else { // // Some submenus have a title element // if (isset($submenu_data['title'])) { // $wrapper->raw($submenu_data['title'])->attr(['class' => 'nav-submenu-title']); // } - - foreach ($child->getChildren() as $subitem) { - $wrapper->add($subitem->getTitle(), $subitem->getHref()); + $wrapper = $parent->raw('')->attr(['class' => 'nav-submenu-wrapper']); + foreach ($child->getChildren() as $subitem) { + $wrapper->add($subitem->getTitle(), $subitem->getHref()); + } } } }