Bitrix Site Manager

CIBlock::Update

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

The function updates a number of properties of an information block with a single call.

Parameters

ParameterDescription
ID Information block ID.
arFields An array of the format Array("field"=>"value", ...). The array contains values of all fields of an information block.

Additionally, the field SITE_ID contains an array of the site identifiers describing sites to which the block is bound.

The field GROUP_ID can be used to set the access permissions for the information block. To do so, set the value of this field to an array of pairs "user_group_id=>access_permission" (see CIBlock::SetPermission()).

Return Values

The function returns true on success, or false otherwise. In case of failure, the property LAST_ERROR contains the error code.

See Also

  • CIBlock::Add
  • Information block fields

    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);
    }
    ?>