Documentation

GetList

CDBResult
CIBlockSection::GetList(
 array arOrder = Array("SORT"=>"ASC"),
 array arFilter = Array(),
 bool bIncCnt = false
);

Returns a filtered and sorted list of sections.

Parameters

ParameterDescription
arOrder Optional sort order. Array of the format Array(by1=>order1[, by2=>order2 [, ..]]) where by is the field for sorting. The field can have the following values:
  • id - section ID;
  • section - parent section ID;
  • name - section name;
  • active - active state;
  • left_margin - left margin;
  • depth_level - section nesting level;
  • sort - sort weight;
  • element_cnt - number of elements in section; effective if only bIncCnt is true;
  • timestamp_x - modification date.
order is the sort order. Can be asc for ascending sorts or desc for descending.
arFilter An array of the format Array("filter field"=>"value" [, ...])
The filter field can be the following:
  • ACTIVE - by the active state (Y|N);
  • GLOBAL_ACTIVE - by the active state with respect to those of parent sections (Y|N);
  • NAME - by name (wildcards [%_] allowed);
  • CODE - by the mnemonic code (wildcards [%_] allowed);
  • EXTERNAL_ID - by the external ID (wildcards [%_] allowed);
  • SECTION_ID - by the parent section ID;
  • DEPTH_LEVEL - by the nesting level;
  • LEFT_BORDER, RIGHT_BORDER - by left and right margins (fields LEFT_MARGIN and RIGHT_MARGIN; see Remarks);
  • ID - by the section ID;
  • IBLOCK_ID - by the ID of the parent information block;
  • IBLOCK_ACTIVE - by the parent information block active state;
  • IBLOCK_NAME - by the information block name (wildcards [%_] allowed);
  • IBLOCK_TYPE - by the information block type;
  • IBLOCK_CODE - by the information block mnemonic code (wildcards [%_] allowed);
  • IBLOCK_EXTERNAL_ID - by the information block external code (wildcards [%_] allowed);
  • PROPERTY - by values of properties of the child elements; PROPERTY is an array of kind Array("property ID"=>"value", ...).
All the filter fields except SECTION_ID and ACTIVE_DATE may have the conditions specified before the name.

The "filter values" are a single value or an array.

The default parameter value is an empty array.
bIncCnt Specifies that the number of sections of the information block is to be returned in the field ELEMENT_CNT. Optional. The default value is false.

Return Values

Returns an instance of CDBResult

Remarks

The sorting field left_margin (the so-called "through sorting") is calculated based on the field sort, nesting level and the parent level sort weight. The difference between sort and left_margin is that the sort is defined by the user to sort sections within a single parent section, while the left_margin is calculated automatically and is used for sorting within the whole information block.

See Also

  • CDBResult
  • Section fields

    Example


    <?
    $arIBTYPE = CIBlockType::GetByIDLang($type, LANGUAGE_ID);
    if($arIBTYPE!==false)
    {
        // select only active sections from the information block $IBLOCK_ID, 
        // having elements with properties "SRC" starting with "https://"
        $arFilter = Array('IBLOCK_ID'=>$IBLOCK_ID,
                          'GLOBAL_ACTIVE'=>'Y',
                          'PROPERTY'=>Array('SRC'=>'https://%'));
        $db_list = CIBlockSection::GetList(Array($by=>$order), $arFilter, true);
        $db_list->NavStart(20);
        echo $db_list->NavPrint($arIBTYPE["SECTION_NAME"]);
        while($ar_result = $db_list->GetNext())
        {
            echo $ar_result['ID'].' '.$ar_result['NAME'].': '.$ar_result['ELEMENT_CNT'].'<br>';
        }
        echo $db_list->NavPrint($arIBTYPE["SECTION_NAME"]);
    }
    ?>
  • © «Bitrix24», 2001-2024