Bitrix Site Manager

CIBlock::Add

int
CIBlock::Add(
 array arFields
);

Adds a new information block.

Parameters

ParameterDescription
arFields An array of the format Array("field"=>"value", ...).

Contains values of all fields of an information block. The field SITE_ID must contain an array of identifiers of the sites to which the new block is to be bound.

The field GROUP_ID with an array of pairs "user group code=>access permission" may be used to set the access permissions for different user groups to the information block (see CIBlock::SetPermission).

Return Values

The method returns the ID of the created information block on success, or false otherwise. In the latter case, the property LAST_ERROR contains the error code.

See Also

  • CIBlock::Update
  • Fields of information blocks

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