Skip to content

Commit

Permalink
FIX Let admins get navigators for their own records
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Oct 7, 2022
1 parent 2d2985c commit e5badb5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions code/LeftAndMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ public function getEditForm($id = null, $fields = null)
// Added in-line to the form, but plucked into different view by frontend scripts.
if ($record instanceof CMSPreviewable || $record->has_extension(CMSPreviewable::class)) {
/** @skipUpgrade */
$navField = new LiteralField('SilverStripeNavigator', $this->getSilverStripeNavigator());
$navField = new LiteralField('SilverStripeNavigator', $this->getSilverStripeNavigator($record));
$navField->setAllowHTML(true);
$fields->push($navField);
}
Expand Down Expand Up @@ -1673,11 +1673,13 @@ public function printable()
*
* @return DBHTMLText
*/
public function getSilverStripeNavigator()
public function getSilverStripeNavigator(?DataObject $record = null)
{
$page = $this->currentPage();
if ($page instanceof CMSPreviewable || $page->has_extension(CMSPreviewable::class)) {
$navigator = new SilverStripeNavigator($page);
if (!$record) {
$record = $this->currentPage();
}
if ($record && (($record instanceof CMSPreviewable) || $record->has_extension(CMSPreviewable::class))) {
$navigator = new SilverStripeNavigator($record);
return $navigator->renderWith($this->getTemplatesWithSuffix('_SilverStripeNavigator'));
}
return null;
Expand Down

0 comments on commit e5badb5

Please sign in to comment.