Bitrix Site Manager

CMain::GetSiteByDir

array
CMain::GetSiteByDir(
 mixed path = false,
 mixed host = false
)

The method GetSiteByDir returns an array describing the site defined by the specified path and domain. 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..

Parameters

ParameterDescription
path Path relative to the root .
Optional; the default value is the path to the current page.
host Domain name.
Optional; the default value is the current domain.

Return Values

Array describing the site with keys described in the CSite fields section.

See Also

Example



<?
// 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"]);
?>