diff --git a/src/Model/MenuItem.php b/src/Model/MenuItem.php index 25d3a5a..31edd9c 100644 --- a/src/Model/MenuItem.php +++ b/src/Model/MenuItem.php @@ -292,8 +292,10 @@ public function CMSEditLink() ); } else if ($this->MenuSetID) { + $link = $this->MenuSet()->CMSEditLink(); + $link = preg_replace('/\/item\/([\d]+)\/edit/', '/item/$1', $link); $link = Controller::join_links( - $this->MenuSet()->CMSEditLink(), + $link, 'ItemEditForm/field/Items/item', $this->ID ); diff --git a/src/Model/MenuSet.php b/src/Model/MenuSet.php index 5d8ddcb..44bc962 100644 --- a/src/Model/MenuSet.php +++ b/src/Model/MenuSet.php @@ -440,6 +440,31 @@ public function getCMSFields() $this->extend('updateCMSFields', $fields); return $fields; } + + public function CMSEditLink() + { + $link = null; + if ($this->ParentID) { + if (is_a($this->Parent(), SiteTree::class)) { + $link = Controller::join_links( + singleton(CMSPageEditController::class)->Link('EditForm'), + $this->ParentID, + 'field/MenuSets/item', + $this->ID, + 'edit' + ); + } elseif (is_a($this->Parent(), SiteConfig::class)) { + $link = Controller::join_links( + singleton(SiteConfigLeftAndMain::class)->Link('EditForm'), + 'field/MenuSets/item', + $this->ID, + 'edit' + ); + } + } + $this->extend('updateCMSEditLink', $link); + return $link; + } public function canCreate($member = null, $context = null) {