diff --git a/code/controllers/RootURLController.php b/code/controllers/RootURLController.php index 5d01e32d..56aef850 100644 --- a/code/controllers/RootURLController.php +++ b/code/controllers/RootURLController.php @@ -54,6 +54,16 @@ class RootURLController extends Controller { return self::$cached_homepage_link; } + /** + * Set the URL Segment used for your homepage when it is created by dev/build. + * This allows you to use home page URLs other than the default "home". + * + * @param string $urlsegment the URL segment for your home page + */ + public static function set_default_homepage_link($urlsegment = "home") { + self::$default_homepage_link = $urlsegment; + } + /** * Gets the link that denotes the homepage if there is not one explicitly defined for this HTTP_HOST value. * diff --git a/code/model/SiteTree.php b/code/model/SiteTree.php index c6cc9c9f..94ef9062 100644 --- a/code/model/SiteTree.php +++ b/code/model/SiteTree.php @@ -1328,11 +1328,11 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid // default pages if($this->class == 'SiteTree' && self::get_create_default_pages()) { - if(!SiteTree::get_by_link('home')) { + if(!SiteTree::get_by_link(RootURLController::get_default_homepage_link())) { $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 = RootURLController::get_default_homepage_link(); $homepage->Sort = 1; $homepage->write(); $homepage->publish('Stage', 'Live');