Jump to:

23491 Posts in 18996 Topics by 2878 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: 1002 Views
  • patjnr
    Community Member
    101 Posts

    Changing the ParentID onBeforeWrite Link to this post


    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;

    its changing the "ShowInMenus " but not the ParentID

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



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.