There is a button that leads to the associated catalog item . And it is necessary that led to the attached section of the directory.

result_modifier

<? if (!empty($arResult['ITEMS'])) { $relItemIDS = array(); foreach ($arResult['ITEMS'] as $arItem) if (intval($arItem['PROPERTIES']['RELATED_ITEM']['VALUE'])) $relItemIDS[] = intval($arItem['PROPERTIES']['RELATED_ITEM']['VALUE']); if (!empty($relItemIDS)) { $resItems = CIBlockElement::GetList(array(), array('ID' => array_unique($relItemIDS)), false, false, array('NAME', 'DETAIL_PAGE_URL')); while ($arItem = $resItems->GetNext()) { $arResult['RELATED_ITEMS'][$arItem['ID']] = $arItem; } } } ?> 

template

 <?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die(); $this->setFrameMode(true);?> <?if (!empty($arResult['ITEMS'])):?> <div class="owl-carousel main-slider"> <?foreach ($arResult['ITEMS'] as $arItem): if (intval($arItem['PREVIEW_PICTURE'])): $pic = CFile::ResizeImageGet($arItem['PREVIEW_PICTURE'], array('width' => 1900, 'height' => 574), BX_RESIZE_IMAGE_EXACT, true); $detailUrl = $arResult['RELATED_ITEMS'][$arItem['PROPERTIES']['RELATED_ITEM']['VALUE']]['DETAIL_PAGE_URL']; $blockSelector = ($detailUrl) ? 'a' : 'div';?> <? $this->AddEditAction($arItem['ID'], $arItem['EDIT_LINK'], CIBlock::GetArrayByID($arItem["IBLOCK_ID"], "ELEMENT_EDIT")); $this->AddDeleteAction($arItem['ID'], $arItem['DELETE_LINK'], CIBlock::GetArrayByID($arItem["IBLOCK_ID"], "ELEMENT_DELETE"), array("CONFIRM" => GetMessage('CT_BNL_ELEMENT_DELETE_CONFIRM'))); ?> <div class="item vertical-middle" id="<?=$this->GetEditAreaId($arItem['ID']);?>"> <<?=$blockSelector?><?if ($detailUrl):?> href="<?=$detailUrl?>"<?endif;?> class="background <?=($arItem['PROPERTIES']['STYLE']['VALUE_XML_ID'] == 'white') ? 'white' : 'black'?>" style="background-image:url(<?=$pic['src']?>);"> <span class="container row"> <span class="main-slider-caption"><?=$arItem['NAME']?></span> <span class="main-slider-desc"><?=$arItem['PREVIEW_TEXT']?></span> <?if ($detailUrl):?> <span class="button hide-for-small-only"><?=GetMessage("MORE")?></span> <?endif;?> </span> </<?=$blockSelector?>> </div> <?endif; endforeach;?> </div> <?endif;?> 

Binding to an item with us is "RELATED_ITEM". And the section binding code is "RELATED_SECTION".

Help, how to modify these files so that when you click on the button we get into the associated section.

  • What prevents to use RELATED_SECTION instead of RELATED_ITEM and dev.1c-bitrix.ru/api_help/iblock/classes/ciblocksection/… ? - Oleksandr
  • @AK I'm relatively new to this CMS, just replacing one with another does not help, I did it right away. I also changed CIBlockElement :: GetList to CIBlockSection :: GetList - Mikhail Bulash
  • Look in what parameters of the arItem array the arItem binding is stored. var_dump to help you. Well, use the appropriate API to work with sections. When you see in which parameters of the array the necessary data is stored, the problem will go away. - Nikolaj Sarry
  • I figured it out, did not correctly pass the parameters to CIBlockSection :: GetList That's how it worked. 'if (! empty ($ relItemIDSB)) {$ resItems = CIBlockSection :: GetList (array (), array (' ID '=> array_unique ($ relItemIDSB)), false, array (' NAME ',' SECTION_PAGE_URL '), false); } ' - Mikhail Bulash

0