Answer the question
In order to leave comments, you need to log in
How to display property values of linked elements in Bitrix?
Hello!
There is infoblock-1, which includes binding to the elements of infoblock-2. The task in the news.detail template of infoblock-1 is to display the values of the properties of the linked elements. It is necessary to display 3 properties from infoblock-2: ADDRESS (string), PHONE (string) and LOGO (file).
So far, it was possible to display anything (property name, ID, etc.), but not their values. Can you please tell me if this is possible at all? If possible, show on some simple example (preferably with a file).
Thanks
Answer the question
In order to leave comments, you need to log in
as a rule, it is done like this:
in the result_modifier of the news.detail template, you need to call getlist , in which we will get the necessary fields of related elements.
Example:
$arSelect = Array("ID", "ACTIVE_TO"); //здесь перечисляем нужные поля из связанных элементов
$arFilter = Array("IBLOCK_ID"=>6, "ACTIVE"=>"Y","ID"=>$_GET["time_id"]); //$_GET["time_id"] - заменить на массив с твоими id связанных записей
$res = CIBlockElement::GetList(array("SORT" => "ASC"), $arFilter, false, Array("nPageSize"=>PHP_INT_MAX), $arSelect);
$time_items = array();
while($ob = $res->GetNextElement())
{
$arFields = $ob->GetFields();
$time_items[] = $arFields;
}
$arResult["TIME_ITEM"] = $time_items;
Your way only shows the value id, then you need to use GetByID
$res = CIBlockElement::GetByID($arResult["TIME_ITEM"]['0']['PROPERTY_USLUGI_ELEMENT_VALUE']);
if($ar_res = $res->GetNext())
echo $ar_res['NAME'];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question