Bitrix Site Manager

CChapter::Add

int
CChapter::Add(
 array arFields
);

The Add method adds a new chapter.

Parameters

ParameterDescription
arFields The array Array("field"=>"value", ...). Contains values of all chapter fields. Required fields must be present.

Return Values

The method returns the ID of the added chapter on success, or false otherwise. If an error occurs, the exception will contain the error description.

See Also

  • CChapter::Update
  • Chapter fields
  • Example

    
    if (CModule::IncludeModule("learning"))
    {
        $COURSE_ID = 97;
    
        $arFields = Array(
            "COURSE_ID" => $COURSE_ID,
            "ACTIVE" => "Y",
            "NAME" => "Chapter 1",
            "SORT" => "100",
            "DETAIL_TEXT" => "In this chapter ...",
        );
    
        $chapter = new CChapter;
        $ID = $chapter->Add($arFields);
        $success = ($ID>0);
    
        if($success)
        {
            echo "Ok!";
        }
        else
        {
            if($e = $APPLICATION->GetException())
                echo "Error: ".$e->GetString();
        }
    
    }
    ?>