There are a few things missing from your code and a few things that need to be fixed:
- When creating the new page call
new Programme()
rather thannew SiteTree()
- You should not set the
ClassName
, the above change will take care of this - There is no need to set the
URLSegment
. Silverstripe will automatically do this based on the Title you set - Make sure a page with ID 86 exists
- You need to call
->publish('Stage', 'Live')
and->flushCache()
The following code should work:
$mySiteTree = new Programme();
$mySiteTree->Title = 'testing title';
$mySiteTree->ShowInMenus = '1';
$mySiteTree->ParentID = '86';
$mySiteTree->write();
$mySiteTree->publish('Stage', 'Live');
$mySiteTree->flushCache();