Bitrix Site Manager

CChapter::GetList

CDBResult
CChapter::GetList(
 array arOrder = Array("TIMESTAMP_X"=>"DESC"),
 array arFilter = Array(),
 bool bIncCnt = false
);

The GetList method returns the list of chapters filtered by arFilter and sorted in the arOrder order. The current user access permissions are considered.

Parameters

ParameterDescription
arOrder An array in the format array("filter field"=>"sort order" [, ...]). The sorting field can have the following values:
  • ID - the chapter ID;
  • NAME - the chapter name;
  • ACTIVE - active state flag;
  • SORT - sort index;
  • TIMESTAMP_X - the date when the chapter was modified.
Sort order can be one of the following:
  • asc - ascending;
  • desc - descending;

    Optional. The default is the descending order.
arFilter An array in the format array("filtered field"=>"filter value" [, ...]). The following values are possible:
  • ID - the chapter ID;
  • NAME - the chapter name (wildcards allowed: [%_]);
  • SORT - sort index;
  • CODE - mnemonic chapter name (wildcards allowed: [%_]);
  • ACTIVE - active state flag (Y|N);
  • TIMESTAMP_X - the date when the chapter was modified;
  • CHAPTER_ID - the chapter ID. To obtain a list of parent chapters, set this item to an empty string;
  • COURSE_ID - the course ID;
  • DETAIL_TEXT - filter by an entry in the detailed description (wildcards allowed: [%_]);
  • PREVIEW_TEXT - short chapter description (wildcards allowed: [%_]);
  • MIN_PERMISSION - minimum access permission level. "R" by default. See CCourse::SetPermission for available access permissions.
  • CHECK_PERMISSIONS - the level of access permission will be checked. If set to "N", the check is not performed;
  • CNT_ACTIVE - if set bIncCnt to true, only active lessons will be counted.
The following logic can be specified at the beginning of the field name:
  • "!" - not equal;
  • "<" - less than;
  • "<=" - less or equal;
  • ">" - more than;
  • ">=" - more or equal.

"filter values"  is a single value or an array.

Optional. By default, records are not filtered.
bIncCnt Defines whether the number of chapter lessons is to be returned in ELEMENT_CNT. Optional, false by default.

Return Values

The method returns an instance of the CDBResult object.

See Also

  • CDBResult
  • CChapter::GetByID
  • Chapter fields

    Examples

    
    <?
    if (CModule::IncludeModule("learning"))
    {
        $COURSE_ID = 97;
        $res = CChapter::GetList(
            Array("SORT"=>"ASC"), 
            Array("ACTIVE" => "Y", "COURSE_ID" => $COURSE_ID, "CNT_ACTIVE" => "Y"),
            true
        );
    
        while ($arChapter = $res->GetNext())
        {
            echo "Chapter name: ".$arChapter["NAME"]."<br>";
            echo "Active lessons: ".$arChapter["ELEMENT_CNT"]."<br><br>";
        }
    }
    ?>

    
    <?
    
    if (CModule::IncludeModule("learning"))
    {
        $res = CChapter::GetList(
            Array("SORT"=>"ASC"), 
            Array("?NAME" => "Site")
        );
    
        while ($arChapter = $res->GetNext())
        {
            echo "Chapter name: ".$arChapter["NAME"]."<br>";
        }
    }
    ?>

    
    <?
    
    if (CModule::IncludeModule("learning"))
    {
        $COURSE_ID = 97;
    
        $res = CChapter::GetList(
            Array("NAME" => "ASC", "SORT"=>"ASC"), 
            Array("COURSE_ID" => $COURSE_ID)
        );
    
        while ($arChapter = $res->GetNext())
        {
            echo "Chapter name: ".$arChapter["NAME"]."<br>";
        }
    }
    ?>

    
    <?
    
    if (CModule::IncludeModule("learning"))
    {
        $COURSE_ID = 97;
    
        $res = CChapter::GetList(
            Array("TIMESTAMP_X" => "ASC", "SORT"=>"ASC"), 
            Array("CHECK_PERMISSIONS" => "N", "CHAPTER_ID" => "", "COURSE_ID" => $COURSE_ID)
        );
    
        while ($arChapter = $res->GetNext())
        {
            echo "Chapter name: ".$arChapter["NAME"]."<br>";
        }
    }
    ?>