]> _ Git - cubist_cms-back.git/commitdiff
fix #3342 @0.75
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 15 Jan 2020 11:12:04 +0000 (12:12 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 15 Jan 2020 11:12:04 +0000 (12:12 +0100)
src/app/Http/Controllers/CubistPageController.php
src/app/Magic/Menu/Item.php
src/app/Magic/Menu/Menu.php
src/app/Magic/Menu/PageItem.php
src/app/Template/Navigation.php
src/app/Template/Redirection.php
src/app/Template/TemplateAbstract.php

index 6c79881faaf3697e3a3a7f2e10d62aa655d1f9cc..ccf32ad9c5919da25c16a127460a74dd6853d01e 100644 (file)
@@ -12,11 +12,11 @@ use Illuminate\Support\Str;
 class CubistPageController extends CubistFrontController
 {
 
-    public function index(Request $request, $slug = 'home')
+    public function index(Request $request, $id)
     {
         $class = CMSPage::getPageClass();
         /** @var CMSPage $page */
-        $page = Menu::getNavigation()->findOneBy('slug', $slug)->getEntity();
+        $page = Menu::getNavigation()->findOneById($id)->getEntity();
 
         if (!$page) {
             $this->_404();
@@ -49,7 +49,8 @@ class CubistPageController extends CubistFrontController
                 $path = 'home';
             }
             $nav = Menu::getNavigation();
-            $item = $nav->findItemWithURL($path);
+            $item = $nav->findItemWithURL($path,true);
+
             if (null === $item) {
                 $redirectItem = $nav->findOneWithAlias($path);
                 if (null !== $redirectItem) {
index 543d5566e0aba27c435b07a9c9a3b5bedff3b0fd..44f82fc1e65b661e27709634833f1660fe58723f 100644 (file)
@@ -272,14 +272,14 @@ class Item
         return null;
     }
 
-    public function findItemWithURL($href)
+    public function findItemWithURL($href, $restrictToNavigable = true)
     {
         foreach ($this->findAllBy('href', $href) as $item) {
             if (!($item instanceof PageItem)) {
                 return $item;
             }
             /** @var $item PageItem */
-            if (stripos($item->getTemplate(), 'redirection') !== false) {
+            if ($restrictToNavigable && !$item->isNavigable()) {
                 continue;
             }
             return $item;
index 9ef7045da1ad350811ff3b678b7f799508660f0a..031f0f4da3ed03948c47834d12d296eda60d6313 100644 (file)
@@ -93,7 +93,7 @@ class Menu extends BaseMenu
                 /** @var PageItem $template */
                 if (null !== $page->getPage()) {
                     $template = $page->getPage()->getUsedTemplate();
-                    if ($template instanceof Redirection || $template instanceof Navigation) {
+                    if (!$template->isNavigable()) {
                         continue;
                     }
                 }
index 91d087636ab35abca1e315234aee30e70c1e6451..6daa4387076ed90d571b426c8094cf28bcaacd44 100644 (file)
@@ -188,7 +188,7 @@ class PageItem extends Item
     public function getController(): array
     {
         if (!$this->_controller) {
-            return ['controller' => 'PageController', 'action' => 'index', 'params' => ['slug' => $this->getSlug()]];
+            return ['controller' => 'PageController', 'action' => 'index', 'params' => ['id' => $this->getId()]];
         }
         return parent::getController();
     }
index 40527eda8b828310003ae3a6676181a0c938a57a..22d285ee5a9c10c1f41eb0dfa501eda1d92c1f0a 100644 (file)
@@ -7,6 +7,7 @@ namespace Cubist\Backpack\app\Template;
 class Navigation extends TemplateAbstract
 {
     protected $_virtual = true;
+    protected $_navigable = false;
 
     public function init()
     {
index 1e9dc48921cea81017921b0f32ca66fd4dce8c29..b979630de70a19eabad49b652a08249eef2d850e 100644 (file)
@@ -6,6 +6,9 @@ namespace Cubist\Backpack\app\Template;
 
 class Redirection extends TemplateAbstract
 {
+
+    protected $_navigable = false;
+
     public function init()
     {
         parent::init();
index 66601739d409c2ea5935c6024e9233a8999c2b00..21dc7d0a986cc73ce63eda9c2de4fdb6f2df32dc 100644 (file)
@@ -16,8 +16,14 @@ class TemplateAbstract
     protected $defaultFieldAttributes = [];
 
     protected $_fields = [];
-
+    /**
+     * @var bool
+     */
     protected $_virtual = false;
+    /**
+     * @var bool
+     */
+    protected $_navigable = true;
 
     public function __construct()
     {
@@ -144,6 +150,14 @@ class TemplateAbstract
         return $this->_virtual;
     }
 
+    /**
+     * @return bool
+     */
+    public function isNavigable()
+    {
+        return $this->_navigable;
+    }
+
 
     /**
      * @param $data array Current page data for the view