Skip to content

Commit

Permalink
fix cms edit links
Browse files Browse the repository at this point in the history
  • Loading branch information
xini committed Dec 22, 2020
1 parent 24b4e3d commit 188c563
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Model/MenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
25 changes: 25 additions & 0 deletions src/Model/MenuSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 188c563

Please sign in to comment.