Answer the question
In order to leave comments, you need to log in
How to display a list of sections and child elements?
Hello!
How to display a list of sections and child elements?
in this form:
section1
- element1
- element2
- element3
section2
- element1
- element2
- element3
, etc.
I have only one section element displayed:
section1
- element1
section2
- element1
<?php
if (CModule::IncludeModule("iblock")){
$iblock_id = 10;
$arFilter = array(
'ACTIVE' => 'Y',
'IBLOCK_ID' => $iblock_id,
'GLOBAL_ACTIVE'=>'Y',
);
$arSelect = array('IBLOCK_ID','ID','NAME');
$arOrder = array('SORT'=>'ASC');
$arSections = CIBlockSection::GetList($arOrder, $arFilter, false, $arSelect);
while($arSection = $arSections->GetNext()){
?>
<div class="faq_section">
<div class="faq_section_title"><?=$arSection['NAME']?></div>
<div class="faq_section_items">
<?php
$_arFilter = array(
'ACTIVE' => 'Y',
'IBLOCK_ID' => $iblock_id,
'GLOBAL_ACTIVE'=>'Y',
'SECTION_ID' => $arSection['ID']
);
$_arSelect = array('IBLOCK_ID','ID','NAME','DETAIL_TEXT');
$arElements = CIBlockElement::GetList($arOrder, $_arFilter, false, $_arSelect);
while($arElement = $arElements->GetNext()){
?>
<div class="faq_item">
<div class="question"><?=$arElement['NAME']?></div>
<div class="answer"><?=$arElement['DETAIL_TEXT']?></div>
</div>
<?php
}
?>
</div>
</div>
<?php
}
}
?>
Answer the question
In order to leave comments, you need to log in
This is called receiving and processing data, grouping elements by section ID, i.e. PHP programming. This can be done in the result_modifier.php file, for example, the news.list or catalog.section component
https://dev.1c-bitrix.ru/learning/course/index.php...
https://dev.1c-bitrix.ru /learning/course/index.php... Form
your resulting array with the necessary keys, and then output in the required form in the component template
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question