GetIBlockSectionList
CDBResult GetIBlockSectionList ( int iblock_id, int section_id = false, array order = Array("LEFT_MARGIN"=>"ASC"), int cnt = 0, array arFilter = Array() );
The function returns active sections of an information block iblock_id.
Parameters
Parameter | Description |
---|---|
iblock_id | The ID of an information block to search for sections. |
section_id | The ID of the parent section. To obtain the root sections of an information
block, set the parameter section_id to 0. Optional. By default (false), all records are returned without restrictions. |
order | 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:
Default value is Array("sort"=>"asc"). Full list of sorting fields and additional information can be found in CIBlockElement::GetList() |
cnt | Maximum number of the returned records. Optional. All records are returned by default. |
arFilter | Optional additional filter by fields in the form of Array("Filtered field"=>"Value",
...). The
Filtered field can be the following:
By default, no additional filtering applied. Full list of sorting fields and additional information can be found in CIBlockElement::GetList() |
Return Values
The function returns an instance of CDBResult containing the active sections, i.e. those of active information blocks and contained in active parent sections.
Remarks
- To facilitate handling the function return values, you can use the method CDBResult::GetNext() returning an array of the information block element fields. All fields returned by this method are HTML compliant and safe. If the result is empty or the end of collection is reached, false is returned.
- 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
Example
<? require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php"); $APPLICATION->SetTitle("Catalog"); if(CModule::IncludeModule("iblock")) { // if $ID is not specified or is not a number, it is assumed to be 0; // select root sections $ID = IntVal($_GET['ID']); // select sections from the information block $BID and section $ID $items = GetIBlockSectionList($_GET['BID'], $ID, Array("sort"=>"asc"), 10); while($arItem = $items->GetNext()) { echo '<a href="catalog.php?bid='.urlencode($_get['bid']). '&ID='.$arItem['ID'].'">'.$arItem["NAME"].'</a><br>'; echo $arItem["DESCRIPTION"]."<br>"; } } else ShowError("The module is not installed"); require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php"); ?>
© «Bitrix24», 2001-2024