diff --git a/code/PhotoGalleryPage.php b/code/PhotoGalleryPage.php index 6e5fb4f..dab8b1d 100644 --- a/code/PhotoGalleryPage.php +++ b/code/PhotoGalleryPage.php @@ -47,7 +47,7 @@ public function getCMSFields() { function onBeforeWrite() { // Move to Photo Gallery Holder if created under something else - if ($this->Parent()->ClassName != "PhotoGalleryHolder") { + if ($this->Parent()->ClassName != "PhotoGalleryHolder" && PhotoGalleryHolder::get()->count() > 0) { $this->ParentID = PhotoGalleryHolder::get()->first()->ID; }