]> _ Git - cubist_cms-back.git/commitdiff
wip #2922 @0:15
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 6 Sep 2019 09:46:14 +0000 (11:46 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 6 Sep 2019 09:46:14 +0000 (11:46 +0200)
src/app/Magic/Menu/Menu.php
src/app/Magic/Menu/PageItem.php

index 1c707e4cf4e5ffad32832113c31ea8982310276e..729077721781c89a8b073a222e39c908d3dc5b3d 100644 (file)
@@ -145,9 +145,12 @@ class Menu extends BaseMenu
     public function makeStandardMenu($menu, $item)
     {
         foreach ($item->getChildren() as $child) {
+            if (!$child->isMenuDesktop()) {
+                continue;
+            }
             $parent = $menu->add($child->getTitle(), $child->getHref());
             // Handle items with submenus
-            if ($child->hasChildren()) {
+            if ($child->isMenuDesktopChildren()) {
                 foreach ($child->getChildren() as $subitem) {
                     $parent->add($subitem->getTitle(), $subitem->getHref());
                 }
@@ -159,18 +162,20 @@ class Menu extends BaseMenu
      * @param $menu Menu
      * @param $item Item
      */
-    public function makeMobileMenu($menu, $item, $depth = 3)
+    public function makeMobileMenu($menu, $item)
     {
-        if ($depth == 0) {
-            return;
-        }
         foreach ($item->getChildren() as $child) {
+            if (!$child->isMenuMobile()) {
+                continue;
+            }
             if ($child->isNavigable()) {
                 $parent = $menu->add($child->getTitle(), $child->getHref());
             } else {
                 $parent = $menu->raw('<span>' . $child->getTitle() . '</span>');
             }
-            $this->makeMobileMenu($parent, $child, $depth - 1);
+            if ($child->isMenuMobileChildren()) {
+                $this->makeMobileMenu($parent, $child);
+            }
         }
     }
 
index 4f491f5791647ff2f41d0c80d7495cfe6f121b15..ad04716d9291b0cbbfaa85f6b8746ca7b8069899 100644 (file)
@@ -44,10 +44,13 @@ class PageItem extends Item
         $this->setSlug($entity->slug);
         $this->setTitle($entity->title);
 
+        $desktop = $entity->menu_desktop == '' ? 'children' : $entity->menu_desktop;
+
         $this->setMenuDesktop($entity->menu_desktop != 'no');
         $this->setMenuDesktopChildren($entity->menu_desktop == 'children');
 
-        $mobile = $entity->menu_mobile == 'desktop' ? $entity->menu_desktop : $entity->menu_mobile;
+        $mobile = $entity->menu_mobile == 'desktop' || $entity->menu_mobile == '' ? $desktop : $entity->menu_mobile;
+
         $this->setMenuMobile($mobile != 'no');
         $this->setMenuMobileChildren($mobile == 'children');