本文整理汇总了PHP中Craft::getSiteUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Craft::getSiteUrl方法的具体用法?PHP Craft::getSiteUrl怎么用?PHP Craft::getSiteUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Craft
的用法示例。
在下文中一共展示了Craft::getSiteUrl方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSiteUrl
/**
* Returns the site URL.
*
* @return string
*/
public function getSiteUrl()
{
return Craft::getSiteUrl();
}
示例2: _getUrl
/**
* Returns a URL.
*
* @access private
* @param string $path
* @param array|string $params
* @param $protocol
* @param $dynamicBaseUrl
* @param $mustShowScriptName
* @return string
*/
private static function _getUrl($path, $params, $protocol, $dynamicBaseUrl, $mustShowScriptName)
{
$anchor = '';
// Normalize the params
if (is_array($params)) {
foreach ($params as $name => $value) {
if (!is_numeric($name)) {
if ($name == '#') {
$anchor = '#' . $value;
} else {
if ($value !== null && $value !== '') {
$params[] = $name . '=' . $value;
}
}
unset($params[$name]);
}
}
$params = implode('&', array_filter($params));
} else {
$params = ltrim($params, '&?');
}
if ($dynamicBaseUrl) {
$baseUrl = craft()->request->getHostInfo($protocol) . craft()->urlManager->getBaseUrl();
if (!$mustShowScriptName && craft()->config->omitScriptNameInUrls()) {
$baseUrl = substr($baseUrl, 0, strrpos($baseUrl, '/'));
}
} else {
$baseUrl = Craft::getSiteUrl($protocol);
if ($mustShowScriptName || !craft()->config->omitScriptNameInUrls()) {
$baseUrl .= strrchr(craft()->urlManager->getBaseUrl(), '/');
}
}
// Put it all together
if (craft()->config->usePathInfo()) {
return $baseUrl . ($path ? '/' . $path : '') . ($params ? '?' . $params : '') . $anchor;
} else {
$pathParam = craft()->urlManager->pathParam;
return $baseUrl . ($path || $params ? '?' . ($path ? $pathParam . '=' . $path : '') . ($path && $params ? '&' : '') . $params : '') . $anchor;
}
}
示例3: getGlobals
/**
* Returns a list of global variables to add to the existing list.
*
* @return array An array of global variables
*/
public function getGlobals()
{
// Keep the 'blx' variable around for now
$craftVariable = new CraftVariable();
$globals['craft'] = $craftVariable;
$globals['blx'] = $craftVariable;
$globals['now'] = DateTimeHelper::currentUTCDateTime();
$globals['loginUrl'] = UrlHelper::getUrl(craft()->config->getLoginPath());
$globals['logoutUrl'] = UrlHelper::getUrl(craft()->config->getLogoutPath());
if (Craft::isInstalled()) {
$globals['siteName'] = Craft::getSiteName();
$globals['siteUrl'] = Craft::getSiteUrl();
$globals['user'] = craft()->userSession->getUser();
if (craft()->request->isSiteRequest()) {
foreach (craft()->globals->getAllSets() as $globalSet) {
$globalSet->locale = craft()->language;
$globals[$globalSet->handle] = $globalSet;
}
}
} else {
$globals['siteName'] = null;
$globals['siteUrl'] = null;
$globals['user'] = null;
}
return $globals;
}