A
A
Alexander Ivanov2016-04-04 15:23:34
1C-Bitrix
Alexander Ivanov, 2016-04-04 15:23:34

How to display the name of the parent of the news in the Bitrix news list?

This is how I display a link to the news parent:

<? preg_match("/\/(.*)\/(.*)\/(.*)\//",$arItem["DETAIL_PAGE_URL"], $matches);?>
<a href="<?foreach($matches as $key=>$valuer){if($key == 12){echo "/".$matches[1]."/".$matches[2]."/";}}?>" class="red">  <?  echo "ИМЯ РОДИТЕЛЯ НОВОСТИ"?>
</a>
<h3>Заголовок новости -<?=$arItem["NAME"]?></h3>
// $arResult["SECTION"]["PATH"][0]["NAME"] -

Apparently the name of the parent should be displayed through such constructions CIBlockSection::GetList .... but there is not enough knowledge.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2016-04-05
@cimonlebedev

I dug Bitrix on the forum, after all I was close

<?foreach($arResult["ITEMS"] as $key=>$arItem):
            $res = CIBlockSection::GetByID($arItem["IBLOCK_SECTION_ID"]);
            if($ar_res = $res->GetNext())
            echo $arResult["ITEMS"][$key]["IBLOCK_SECTION_NAME"] = $ar_res['NAME'];
          endforeach;?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question