mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #54 from jthomerson/allow_different_homepage_url_master
ENHANCEMENT: Allow the homepage to have a different URL.
This commit is contained in:
commit
01cef8a86d
@ -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.
|
||||
*
|
||||
|
@ -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', '<p>Welcome to SilverStripe! This is the default homepage. You can edit this page by opening <a href="admin/">the CMS</a>. You can now access the <a href="http://doc.silverstripe.org">developer documentation</a>, or begin <a href="http://doc.silverstripe.org/doku.php?id=tutorials">the tutorials.</a></p>');
|
||||
$homepage->URLSegment = 'home';
|
||||
$homepage->URLSegment = RootURLController::get_default_homepage_link();
|
||||
$homepage->Sort = 1;
|
||||
$homepage->write();
|
||||
$homepage->publish('Stage', 'Live');
|
||||
|
Loading…
Reference in New Issue
Block a user