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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Changing the ParentID onBeforeWrite


Go to End


1455 Views

Avatar
patjnr

Community Member, 102 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