Answer the question
In order to leave comments, you need to log in
Bitrix, queries to the database?
There was a task to make a menu in Bitrix. In this static menu, it was necessary to grab the elements of the infoblock by the section url specified in the menu itself and display them in the submenu. I wrote such code in result_modifier.php
<? if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED!==true) die();
$arFilter = Array('IBLOCK_ID'=>$IBLOCK_ID, 'GLOBAL_ACTIVE'=>'Y');
$db_list = CIBlockSection::GetList(Array($by=>$order), $arFilter, true);
while($ar_result = $db_list->GetNext())
{
foreach ($arResult as $key => $arItem) {
$test = explode('/', $arItem["LINK"]);
if ($test[(count($test) - 2)] == $ar_result["CODE"]) {
$arResult[$key]["CHILDREN"] = array();
$arSelect = Array("ID", "NAME", "DETAIL_PAGE_URL");
$arFilter = Array("IBLOCK_ID"=>$IBLOCK_ID, "ACTIVE"=>"Y", "SECTION_ID" => $ar_result["ID"]);
$res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect);
$i=0;
while($ob = $res->GetNextElement())
{
$arFields = $ob->GetFields();
$arResult[$key]["CHILDREN"][$i]["NAME"] = $arFields["NAME"];
$arResult[$key]["CHILDREN"][$i]["DETAIL_PAGE_URL"] = $arFields["DETAIL_PAGE_URL"];
$i ++;
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question