コード例 #1
0
 /**
  * Get the RelativeLink value for a home page in another locale. This is found by searching for the default home
  * page in the default language, then returning the link to the translated version (if one exists).
  *
  * @return string
  */
 public static function get_homepage_link_by_locale($locale)
 {
     $originalLocale = self::get_current_locale();
     self::set_current_locale(self::default_locale());
     $original = SiteTree::get_by_link(RootURLController::config()->default_homepage_link);
     self::set_current_locale($originalLocale);
     if ($original) {
         if ($translation = $original->getTranslation($locale)) {
             return trim($translation->RelativeLink(true), '/');
         }
     }
 }