Documentation

Update

Description and parameters

bool CIBlock::Update(
 int ID,
 array arFields
);

Method updates parameters for iblock with ID. You can modify fields as well as cancel parameter edit by adding the event handler OnBeforeIBlockUpdate. Upon successful adding of iblock, the event handler OnAfterIBlockUpdate is added. Non-static method.

Call parameters

ParametersDescription
IDUpdated iblock ID.
arFieldsArray("field"=>"value", ...). Contains values for all iblock fields.
Additionally, the field SITE_ID can contain the array with site IDs with modified iblock bound.
Also, you can set access permissions for various groups to the iblock using the field "GROUP_ID", containing array with group codes matchings with corresponding access permissions. See CIBlock::SetPermission()).
When the field "FIELDS" is set, executes field settings (see. CIBlock::SetFields).

Returned value

Method returns true on success, or false on error and object's property LAST_ERROR will contain error text.

See Also

Example

<?
$arPICTURE = $_FILES["PICTURE"];
$ib = new CIBlock;
$arFields = Array(
"ACTIVE" => $ACTIVE,
"NAME" => $NAME,
"CODE" => $CODE,
"LIST_PAGE_URL" => $LIST_PAGE_URL,
"DETAIL_PAGE_URL" => $DETAIL_PAGE_URL,
"IBLOCK_TYPE_ID" => $type,
"SITE_ID" => Array("en", "de"),
"SORT" => $SORT,
"PICTURE" => $arPICTURE,
"DESCRIPTION" => $DESCRIPTION,
"DESCRIPTION_TYPE" => $DESCRIPTION_TYPE,
"GROUP_ID" => Array("2"=>"D", "3"=>"R")
);
if ($ID > 0)
$res = $ib->Update($ID, $arFields);
else
{
$ID = $ib->Add($arFields);
$res = ($ID>0);
}
?>

© «Bitrix24», 2001-2024
Up