Version: current

     1 <?php
     2 /**
     3  * Задача изменения типа (на SubsitesSelectorPage) главной станицы (/home) основного подсайта
     4  *
     5  */
     6 class SetMainSiteHomePageTypeTask extends BuildTask {
     7
     8     function run($request) {
     9         if (!Director::is_cli() && !Permission::check("ADMIN") ) {
    10             return print "Permission denied";
    11         }
    12
    13         if ($pages = Subsite::get_from_all_subsites('SiteTree', "ParentID = 0 AND URLSegment = 'home' AND SubsiteID = 0")) {
    14             $homePage = $pages->First();
    15         } else {
    16             $homePage = new HomePage();
    17             $homePage->Title = _t('SiteTree.DEFAULTHOMETITLE', 'Home');
    18             $homePage->URLSegment = 'home';
    19             $homePage->Sort = 1;
    20             $homePage->write();
    21             $homePage->doPublish();
    22         }
    23         $homePage->ClassName = 'SubsitesSelectorPage';
    24         $homePage->GotoSubsite = -1;
    25         $homePage->Title = _t('SubsitesSelectorPage.SINGULARNAME', 'Subsites Selector Page');
    26         $homePage->write();
    27         $homePage->doPublish();
    28     }
    29 }

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -