GetIBlockElementList
CIBlockResult GetIBlockElementList( int iblock_id, int section_id = false, array order = Array("SORT"=>"ASC"), int cnt = 0, array arFilter = Array() );
The function returns active elements of the information block defined by iblock_id.
Parameters
Parameter | Description |
---|---|
iblock_id | The ID of the information block to search for elements. |
section_id | The ID of the section to search for elements. Set section_id to 0 to obtain elements from the information block root. Optional. By default (false), the function selects all records without any 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 one of the following:
The fields SECTION_ID and ACTIVE_DATE may have negation sign ("!") before the name. The "filter values" are a single value or an array. The default parameter value is an empty array. Full list of sorting fields and additional information can be found in CIBlockElement::GetList() |
Return Values
The function returns an instance of CIBlockResult with active elements, i.e. those having the flag Active set, valid active period and pertaining to the active parent information blocks of the current site.
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. Variables #SITE_DIR#
, #IBLOCK_ID#
, #EXTERNAL_ID#
and #ID#
are replaced with their corresponding values
(fields LIST_PAGE_URL and DETAIL_PAGE_URL). If the result is empty or the end of
collection is reached, false
is returned. Other methods of the CDBResult class can also be used, but
keep in mind that they do not substitute variables like #SITE_DIR#
with their values.
See Also
Example
<? if(CModule::IncludeModule("iblock")) { // select 10 elements from the section $ID of the information block $BID $items = GetIBlockElementList($_GET['BID'], $_GET['ID'], Array("SORT"=>"ASC"), 10); $items->NavPrint("Products"); while($arItem = $items->GetNext()) { echo $arItem["NAME"]."<br>"; echo $arItem["PREVIEW_TEXT"]."<br>"; } $items->NavPrint("Products"); } ?>