本文整理匯總了PHP中Translatable::get_homepage_urlsegment_by_locale方法的典型用法代碼示例。如果您正苦於以下問題:PHP Translatable::get_homepage_urlsegment_by_locale方法的具體用法?PHP Translatable::get_homepage_urlsegment_by_locale怎麽用?PHP Translatable::get_homepage_urlsegment_by_locale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Translatable
的用法示例。
在下文中一共展示了Translatable::get_homepage_urlsegment_by_locale方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: get_homepage_urlsegment
/**
* Return the URL segment for the current HTTP_HOST value
*
* @param string $locale
* @return string
*/
static function get_homepage_urlsegment()
{
$urlSegment = '';
// @todo Temporarily restricted to MySQL database while testing db abstraction
if (DB::getConn() instanceof MySQLDatabase) {
$host = $_SERVER['HTTP_HOST'];
$host = str_replace('www.', '', $host);
$SQL_host = str_replace('.', '\\.', Convert::raw2sql($host));
$homePageOBJ = DataObject::get_one("SiteTree", "HomepageForDomain REGEXP '(,|^) *{$SQL_host} *(,|\$)'");
} else {
$homePageOBJ = null;
}
if (singleton('SiteTree')->hasExtension('Translatable') && !$homePageOBJ) {
$urlSegment = Translatable::get_homepage_urlsegment_by_locale(Translatable::get_current_locale());
} elseif ($homePageOBJ) {
$urlSegment = $homePageOBJ->URLSegment;
}
return $urlSegment ? $urlSegment : self::get_default_homepage_urlsegment();
}