$arFilter = array('ACTIVE' => 'Y'); $arOrder = array('SORT' => 'ASC'); $rsBlocks = CIBlock::GetList($arOrder, $arFilter); while ($arBlock = $rsBlocks->Fetch()) { echo $arBlock['ID'] . ': ' . $arBlock['NAME'] . '
'; }
$arFilter = array( 'IBLOCK_ID' => 5, 'ACTIVE' => 'Y' ); $arOrder = array('SORT' => 'ASC'); $rsElements = CIBlockElement::GetList($arOrder, $arFilter); while ($arElement = $rsElements->Fetch()) { echo $arElement['ID'] . ': ' . $arElement['NAME'] . 'Description: This code sets up a filter to only show active elements in the block with ID 5, then sorts them by ascending order of the SORT field. The function retrieves the elements and stores them in a result object. Finally, a loop is used to output each element's ID and name. Package library: Bitrix Framework for PHP.
'; }