Skip to content

Commit

Permalink
Merge pull request #12 from dynamic/2024_05_28_createTemplateFromPage
Browse files Browse the repository at this point in the history
BUGFIX check array_key_exists() for page types with elemental area
  • Loading branch information
muskie9 authored May 28, 2024
2 parents b0942e8 + a2f344a commit a8d24ce
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Extension/SiteTreeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,18 @@ public function updateCMSActions(FieldList $actions): void
$canCreate = Template::singleton()->canCreate();
$hasElementalArea = Template::getDecoratedBy(ElementalAreasExtension::class, DataObject::class);

if ($canCreate && in_array($this->getOwner()->ClassName, $hasElementalArea)) {
$actions->addFieldToTab(
'ActionMenus.MoreOptions',
if ($canCreate && array_key_exists($this->getOwner()->ClassName, $hasElementalArea)) {
$moreOptions = $actions->fieldByName('ActionMenus.MoreOptions');

if(!$moreOptions) {
return;
}

$moreOptions->insertAfter(
'Information',
FormAction::create('CreateTemplate', 'Create Blocks Template')
->removeExtraClass('btn-primary')
->addExtraClass('btn-secondary')
);
}
}
Expand Down

0 comments on commit a8d24ce

Please sign in to comment.