A
A
advancesss2019-10-08 21:01:22
1C-Bitrix
advancesss, 2019-10-08 21:01:22

How to display multiple properties of the "binding to element" type in Bitrix?

Hello dear programmers. Please tell me what is wrong. I am attaching a code snippet that outputs a multiple property of the "binding to element" type. The elements themselves seem to be displayed (I attached three elements, three elements and it came out), but they are displayed empty, the name and picture are not displayed, an error occurs - prntscr.com/pgkuya

<?foreach($arItem["PROPERTIES"]["DOCTOR"]["VALUE"] as $analog):?>
<?$res = CIBlockElement::GetByID($analog);?> 
<?if($ar_res = $res->GetNext())?> 


<h2><?=$arItem["DOCTOR"]["NAME"]?></h2>
 <img alt="<?=$arItem["DOCTOR"]["NAME"]?>" src="<?=CFile::GetPath($arItem["DOCTOR"]["PREVIEW_PICTURE"])?>">




<?endforeach;?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2019-10-08
@advancesses

You have the query result in the $ar_res array, and the call to $arItem
is correct

<?foreach($arItem["PROPERTIES"]["DOCTOR"]["VALUE"] as $analog):?>
    <?$res = CIBlockElement::GetByID($analog);?> 
    <?if($ar_res = $res->GetNext()):?> 
        <h2><?=$ar_res["NAME"]?></h2>
        <img alt="<?=$ar_res["NAME"]?>" src="<?=CFile::GetPath($ar_res["PREVIEW_PICTURE"])?>">
    <?endif?>
<?endforeach;?>

PS More precisely, it's not right at all, in the presence of a relational database, making queries in a cycle, it doesn't get any worse.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question