]> _ Git - cubist_cms-back.git/commitdiff
#2878
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 10 Jul 2019 18:21:43 +0000 (20:21 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 10 Jul 2019 18:21:43 +0000 (20:21 +0200)
src/app/Magic/Menu/Item.php

index 6ba8316aaa5e048315c4f49e8f9d2e9ba506ce95..db2e6afbcec57a63199366e4fe994a83c3a0aa45 100644 (file)
@@ -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());
+                    }
                 }
             }
         }