Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

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

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

Changing the ParentID onBeforeWrite


Go to End
Reply


1166 Views

Avatar
patjnr

Community Member, 101 Posts

8 April 2010 at 3:23am

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