Documentation

GetSiteByDir

array
CMain::GetSiteByDir(
 mixed cur_dir = false,
 mixed cur_host = false
)

The method returns an array describing the site defined by the specified path and domain. Description of keys for this array can be found at the CSite fields page. The method uses the following algorithm:

  1. Searches for site satisfying both path and host; return the found site on success; otherwise -
  2. Searches for site satisfying the path; return the found site on success; otherwise -
  3. Searches for site satisfying the host; return the found site on success; otherwise -
  4. Return the site for which the Default option is set..

Non-static method.

Parameters

ParameterDescription
cur_dir Path relative to the root.
Optional parameter; the default value is the current page.
cur_host Domain name.
Optional parameter; the default value is the current domain.

See Also

Examples of use

<?
// obtain the referrer URL, or the last URL of the current session
if (strlen($_SERVER["HTTP_REFERER"]) <= 0)
    $referer_url = $_SESSION["SESS_HTTP_REFERER"];
else 
    $referer_url = $_SERVER["HTTP_REFERER"];

// parse URL to get the domain and page
$arUrl = parse_url($referer_url);

// obtain the site descriptor array
$arSite = $APPLICATION->GetSiteByDir($arUrl["path"], $arUrl["host"]);
?>


© «Bitrix24», 2001-2024