Documentation

Add

int
Add(
 array arFields, 
 bool bResort = true,
 bool bUpdateSearch = true
);

The method adds a new section to an information block.

Parameters

ParameterDescription
arFields An array of the format Array("field"=>"value", ...), containing values of the information block section fields.
bResort If set to true, tells to recalculate the left and right margins (fields LEFT_MARGIN and RIGHT_MARGIN). Set this parameter to false if you perform a series of calls. In the latter case, set this parameter to false, perform the required calls and then invoke ReSort.
bUpdateSearch Specifies the section should be indexed for searching right after the save.

Return Values

The method returns the ID of the new section on success. In case of failure, it returns false and sets the property LAST_ERROR to the error description.

See Also

  • CIBlockSection::Update

    Example


    <?
    $bs = new CIBlockSection;
    $arFields = Array(
      "ACTIVE" => $ACTIVE,
      "IBLOCK_SECTION_ID" => $IBLOCK_SECTION_ID,
      "IBLOCK_ID" => $IBLOCK_ID,
      "NAME" => $NAME,
      "SORT" => $SORT,
      "PICTURE" => $_FILES["PICTURE"],
      "DESCRIPTION" => $DESCRIPTION,
      "DESCRIPTION_TYPE" => $DESCRIPTION_TYPE
      );
    
    if($ID > 0)
    {
      $res = $bs->Update($ID, $arFields);
    }
    else
    {
      $ID = $bs->Add($arFields);
      $res = ($ID>0);
    }
    
    if(!$res)
      echo $bs->LAST_ERROR;
    ?>
  • © «Bitrix24», 2001-2024
    Up