From 142bb640ec062e1312777743d542053f08c8c631 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Wed, 13 Oct 2010 01:03:25 +0000 Subject: [PATCH] BUGFIX #5277 Sort of default SiteTree records is now explicitly set to avoid strange ordering set by SiteTree::onBeforeWrite for default records (from r101724) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112028 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/SiteTree.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index 6d7006ded..970b6a42b 100755 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -1295,31 +1295,37 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid if($this->class == 'SiteTree') { if(!SiteTree::get_by_link('home')) { $homepage = new Page(); - $homepage->Title = _t('SiteTree.DEFAULTHOMETITLE', 'Home'); $homepage->Content = _t('SiteTree.DEFAULTHOMECONTENT', '

Welcome to SilverStripe! This is the default homepage. You can edit this page by opening the CMS. You can now access the developer documentation, or begin the tutorials.

'); - $homepage->URLSegment = "home"; + $homepage->URLSegment = 'home'; + $homepage->Status = 'Published'; + $homepage->Sort = 1; $homepage->write(); - $homepage->publish("Stage", "Live"); + $homepage->publish('Stage', 'Live'); $homepage->flushCache(); - DB::alteration_message("Home page created","created"); + DB::alteration_message('Home page created', 'created'); } if(DB::query("SELECT COUNT(*) FROM \"SiteTree\"")->value() == 1) { $aboutus = new Page(); $aboutus->Title = _t('SiteTree.DEFAULTABOUTTITLE', 'About Us'); $aboutus->Content = _t('SiteTree.DEFAULTABOUTCONTENT', '

You can fill this page out with your own content, or delete it and create your own pages.

'); + $aboutus->Status = 'Published'; + $aboutus->Sort = 2; $aboutus->write(); - $aboutus->publish("Stage", "Live"); - DB::alteration_message("About Us created","created"); + $aboutus->publish('Stage', 'Live'); + $aboutus->flushCache(); + DB::alteration_message('About Us page created', 'created'); $contactus = new Page(); $contactus->Title = _t('SiteTree.DEFAULTCONTACTTITLE', 'Contact Us'); $contactus->Content = _t('SiteTree.DEFAULTCONTACTCONTENT', '

You can fill this page out with your own content, or delete it and create your own pages.

'); + $contactus->Status = 'Published'; + $contactus->Sort = 3; $contactus->write(); - $contactus->publish("Stage", "Live"); - + $contactus->publish('Stage', 'Live'); $contactus->flushCache(); + DB::alteration_message('Contact Us page created', 'created'); } }