Documentation

Update

bool
CSite::Update(
 int id,
 array fields
)

The method changes site parameters. Returns true on success, in case of an error the method will return false, and the LAST_ERROR property will contain the error description. Non-static method.

Parameters

ParameterDescription
id Site ID.
fields An array of field values in the format of array("field"=>"value" [, ...]).

See Also

Examples of use

<?
$arFields = Array(
  "ACTIVE"           => "Y",
  "SORT"             => 200,
  "DEF"              => "N",
  "NAME"             => "www.site.com",
  "DIR"              => "/en/",
  "FORMAT_DATE"      => "DD.MM.YYYY",
  "FORMAT_DATETIME"  => "DD.MM.YYYY HH:MI:SS",
  "CHARSET"          => "windows-1251",
  "SITE_NAME"        => "My site",
  "SERVER_NAME"      => "www.site.com",
  "EMAIL"            => "admin@site.com",
  "LANGUAGE_ID"      => "en",
  "DOC_ROOT"         => "",
  "DOMAINS"          => "www.site.com \n site.com"
  );
$obSite = new CSite;
$obSite->Update("ru", $arFields);
if (strlen($obSite->LAST_ERROR)>0) $strError .= $obSite->LAST_ERROR;
?>

How to change site template:

if (strlen($site_id)) {
   $obSite = new CSite();
   $t = $obSite->Update($site_id, array(
      'ACTIVE' => "Y",
      'TEMPLATE'=>array(
         array(
            'CONDITION' => "",
            'SORT' => 1,
            'TEMPLATE' => "new_template"
         ),
      )
   ));
}


© «Bitrix24», 2001-2024