Answer the question
In order to leave comments, you need to log in
How to display a picture of the reference property in a template?
The good
code of the result_modifier file
Chet got confused. And how now in a template that to deduce?
The property in the infblock is "STATUS"
<?
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
use Bitrix\Highloadblock as HL;
use Bitrix\Main\Entity;
if(count($arResult["PROPERTIES"]["STATUS"]["VALUE"])){
$color_codes = [];
foreach($arResult["PROPERTIES"]["STATUS"]["VALUE"] as $color){
$color_codes[] = $color;
}
CModule::IncludeModule('highloadblock');
$arHLBlock = Bitrix\Highloadblock\HighloadBlockTable::getById(4)->fetch(); // 1 - ID HL(!) инфоблока
$obEntity = Bitrix\Highloadblock\HighloadBlockTable::compileEntity($arHLBlock);
$strEntityDataClass = $obEntity->getDataClass();
$resData = $strEntityDataClass::getList(array(
'select' => array('UF_FILE','UF_XML_ID'),
'filter' => array('UF_XML_ID' => $color_codes),
'order' => array('ID' => 'ASC'),
'limit' => 100000
));
$ar_res = [];
while ($arItem = $resData->Fetch()) {
$ar_res[$arItem["UF_XML_ID"]] = $arItem["UF_FILE"];
}
if(!is_array($arResult["DISPLAY_PROPERTIES"]["STATUS"]["DISPLAY_VALUE"])){
$arResult["DISPLAY_PROPERTIES"]["STATUS"]["DISPLAY_VALUE"] = array($arResult["DISPLAY_PROPERTIES"]["STATUS"]["DISPLAY_VALUE"]);
}
foreach($arResult["DISPLAY_PROPERTIES"]["STATUS"]["~VALUE"] as $key=>$color){ // собираем результат
$arResult["DISPLAY_PROPERTIES"]["STATUS"]["DISPLAY_VALUE"][$key] = array(
'NAME'=>$arResult["DISPLAY_PROPERTIES"]["STATUS"]["DISPLAY_VALUE"][$key],
'FILE'=>CFile::GetPath($ar_res[$color])
);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question