diff --git a/src/PageElement.php b/src/PageElement.php index 4c636e5..eb9386d 100755 --- a/src/PageElement.php +++ b/src/PageElement.php @@ -142,11 +142,16 @@ public function onAfterWrite() { parent::onAfterWrite(); - if (Versioned::get_stage() == Versioned::DRAFT) { + if (Versioned::get_stage() == Versioned::DRAFT && $this->isChanged("__Counter", DataObject::CHANGE_VALUE)) { foreach ($this->PageSections() as $section) { $section->__Counter++; $section->write(); } + + foreach ($this->Parents() as $parent) { + $parent->__Counter++; + $parent->write(); + } } } diff --git a/src/PageSection.php b/src/PageSection.php index 25dd1de..68da74f 100644 --- a/src/PageSection.php +++ b/src/PageSection.php @@ -62,7 +62,7 @@ public function onAfterWrite() { parent::onAfterWrite(); - if (!$this->__isNew && Versioned::get_stage() == Versioned::DRAFT) { + if (!$this->__isNew && Versioned::get_stage() == Versioned::DRAFT && $this->isChanged("__Counter", DataObject::CHANGE_VALUE)) { $this->Parent()->__PageSectionCounter++; $this->Parent()->write(); }