M
M
Maxim js2021-02-12 20:15:20
PHP
Maxim js, 2021-02-12 20:15:20

How to display the section name from $arResult['SECTIONS'] in the product card?

get

$arResult['SECTIONS'] = IblockQuery::sections()
    ->filter([
        "ACTIVE" => "Y",
        'IBLOCK_ID' => $arParams['IBLOCK_ID'],
        'SECTION_ID' => $arParams['SECTION_ID'],


    ])->execute()->all();


take out
<? foreach ($arResult['SECTIONS'] as $arSection):?>
            <a href="#" class="card__button"><span><?= $arSection["NAME"];?></span></a>
 <?endforeach;?>


But it turns out that it displays not the parent section of the element, but all the names of the top-level sections.
And you need only the section in which this element lies.
That is, instead of SECTION_1 SECTION_2 SECTION_3, display only SECTION_2, for example

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question