Skip to content

Commit

Permalink
Merge pull request #2779 from creative-commoners/pulls/5/previewable-…
Browse files Browse the repository at this point in the history
…via-extension

ENH Records can be made previewable via an extension
  • Loading branch information
sabina-talipova authored Oct 7, 2022
2 parents e5cea70 + 6ff98c4 commit ea9ce63
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions code/Controllers/CMSMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,9 @@ public function getEditForm($id = null, $fields = null)

// Added in-line to the form, but plucked into different view by LeftAndMain.Preview.js upon load
/** @skipUpgrade */
if ($record instanceof CMSPreviewable && !$fields->fieldByName('SilverStripeNavigator')) {
if (($record instanceof CMSPreviewable || $record->has_extension(CMSPreviewable::class))
&& !$fields->fieldByName('SilverStripeNavigator')
) {
$navField = new LiteralField('SilverStripeNavigator', $this->getSilverStripeNavigator());
$navField->setAllowHTML(true);
$fields->push($navField);
Expand Down Expand Up @@ -1393,7 +1395,7 @@ public function getEditForm($id = null, $fields = null)
]);

// Announce the capability so the frontend can decide whether to allow preview or not.
if ($record instanceof CMSPreviewable) {
if ($record instanceof CMSPreviewable || $record->has_extension(CMSPreviewable::class)) {
$form->addExtraClass('cms-previewable');
}
$form->addExtraClass('fill-height flexbox-area-grow');
Expand Down

0 comments on commit ea9ce63

Please sign in to comment.