Answer the question
In order to leave comments, you need to log in
How to display a section with all elements without splitting?
Hello. Help, please understand. I can't figure out where the error is.
The catalog.section component.
The elements are output.
I programmatically display sections.
There are sections with several elements.
The problem is that the content is split into
1 section -> 1 element.
And it turns out that the partitions
are doubled. That is, the Bus section. Elements: Winter tires, Summer tires.
And in the content it is displayed like this
Tire section
Winter tires Tire
section
Summer tires
And it should be like this.
Section Tires
Winter tires
Summer tires
I can't use the catalog.section.list component - because I still need to retighten
trade offer, but it is in catalog.section
$new_arr = array();
foreach($arResult["ITEMS"] as $arItem){
$new_arr[] = $arItem["IBLOCK_SECTION_ID"];
}
foreach($new_arr as $key => $value){
$arFilter = array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "ID" => $value, "ACTIVE" => "Y");
$arSelect = array("ID", "NAME");
$res = CIBlockSection::GetList(array("SORT" => "DESK"), $arFilter, false, false, $arSelect);
while ($ob = $res->GetNext()){
$value = $ob;
}
$arResult["ITEMS"][$key]["SECTION_NAME"][] = $value;
}
Answer the question
In order to leave comments, you need to log in
A few points that are not directly related to the question:
1. Requests in a cycle are bad. Always avoid it.
2. DESK - wrong sorting direction. Correct DESC.
And now to the point:
As far as I understand, you need to display the elements, grouping them into sections. You correctly (except for requests in a loop) receive sections - only incorrectly draw an output in a template.
Make two cycles: the first for sections, the second for elements.
The first loop will display the title of the section, the second loop will display all the elements of this section.
example
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question