Add EditLink Override

Adds ability to override the "Edit in CMS" link, e.g. to make it jump to editing a DataObject, instead of the page.
This commit is contained in:
James Cocker 2021-09-03 10:03:31 +01:00 committed by GitHub
parent 8df13dce17
commit 476a8d68ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 4 deletions

View File

@ -111,10 +111,19 @@ class BetterNavigatorExtension extends DataExtension
}
}
}
// Only show edit link if user has permission to edit this page
$editLink = array_key_exists('CMSLink', $nav)
&& ($isDev || $this->owner->dataRecord->canEdit() && Permission::check('CMS_ACCESS_CMSMain'))
? $nav['CMSLink']['Link'] : false;
// Only show edit link if user has CMS access
if($isDev || Permission::check('CMS_ACCESS_CMSMain')) {
// Check for edit link override, e.g. for a DataObject
if(method_exists($this->owner, 'CustomBetterNavigatorEditLink')) {
$editLink = $this->owner->CustomBetterNavigatorEditLink();
} else {
// Only show edit link if user has permission to edit this page
$editLink = array_key_exists('CMSLink', $nav)
&& ($this->owner->dataRecord->canEdit())
? $nav['CMSLink']['Link'] : false;
}
}
// Is the logged in member nominated as a developer?
$member = Member::currentUser();