<? if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die();$arFilter = array('IBLOCK_ID' => $arParams['IBLOCK_ID'], "ACTIVE" => "Y");
$db_list = CIBlockSection::GetList(array('SORT' => 'ASC'), $arFilter, true, $arSelect);
$arResult['SECTIONS'] = array();

while ($ar_result = $db_list->GetNext()) {
    $arResult['SECTIONS'][] = $ar_result;
}


if (!empty($arResult["SECTIONS"])) {
    foreach ($arResult["SECTIONS"] as $k => $section) {
        $arResult["SECTIONS"][$k]['ITEMS'] = array();
        $arFilter = array("IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "SECTION_ID" => $section['ID']);
        $res = CIBlockElement::GetList(array("PROPERTY_SORT_PRODUCT" => 'ASC'), $arFilter, false, false,
            $arSelect);

        while ($ob = $res->GetNextElement()) {
            $arItem = $ob->GetFields();
            $arItem['PROPERTIES'] = $ob->GetProperties();
            $arResult["SECTIONS"][$k]['ITEMS'][] = $arItem;
        }
    }

}

// заголовки
$IblockId=67;// инфоблок баннера
$arFilter = Array(
    "IBLOCK_ID"=>$IblockId,
    "ACTIVE"=>"Y",
    "ID"=>386

);
$arSelect = Array("ID", "IBLOCK_ID", "NAME","PREVIEW_TEXT","PROPERTY_TITLE","PROPERTY_TAG");//IBLOCK_ID и ID обязательно должны быть
// указаны,

$res = CIBlockElement::GetList(Array(), $arFilter, false,array('nTopCount'=>1), $arSelect);
while($ob = $res->GetNextElement()) {
    $arItem = $ob->GetFields();
    $arResult['TITLE'] = $arItem['~PROPERTY_TITLE_VALUE']['TEXT'];
    $arResult['TEXT'] = $arItem['PREVIEW_TEXT'];
    $arResult['TAG'] = $arItem['PROPERTY_TAG_VALUE'];

}

