Jump to:

23367 Posts in 18143 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » Changing the ParentID onBeforeWrite

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 984 Views
  • patjnr
    Avatar
    Community Member
    101 Posts

    Changing the ParentID onBeforeWrite Link to this post

    hi

    im trying to promote a page from being a child of ParentPage AA to ParentPAge ZZ afater the page has been published.
    here is what i tried

    public function onBeforeWrite()
       {
          
          $parent = DataObject::get_one("FarmHolder");
          $parentid = $parent->ID;

          $this->ShowInMenus = 1;
          $this->ParentID = $parentid;
          $this->write();
          parent::onBeforeWrite();
       }

    its changing the "ShowInMenus " but not the ParentID

    How do i change the ParentID yet it is an INDEX of SiteTree table structure

    ta

    PAt

    984 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.