A
A
Aricus2021-10-22 13:38:09
1C-Bitrix
Aricus, 2021-10-22 13:38:09

How to get links to multiple files from custom infoblock property?

There is a custom property of the F-IMAGES infoblock. Type - file, plural. Pictures are loaded in it
. How can I get links to all these files in result_modifier.php of infoblock theme? I tried:

$db_props = CIBlockElement::GetProperty($arResult['ITEM']['IBLOCK_ID'], $arResult['ITEM']['ID'], "sort", "asc", array());
$arProps = array();
while($ar_props = $db_props->GetNext()) {
  $arProps[$ar_props['CODE']] = $ar_props['VALUE'];
}

But only one number is obtained, for example
[F_IMAGES] => 91

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aricus, 2021-10-26
@Aricus

As a result, I got a function:

/**
 * Получение пользовательских свойств элемента инфоблока
 * @param string|int $iblockID - ID инфоблока
 * @param string|int $elementID - ID элемента инфоблока
 * @return array
 */
function myGetProps($iblockID, $elementID) {
  $result = [];
  $rsProps = CIBlockElement::GetProperty($iblockID, $elementID, [], []);
  while($arrProps = $rsProps->Fetch()) {
    if ($arrProps['PROPERTY_TYPE'] == 'F') {
      $result[$arrProps['CODE']][] = CFile::GetPath($arrProps['VALUE']);
    } else {
      $result[$arrProps['CODE']][] = $arrProps['VALUE'];
    }
  }
  foreach ($result as $name => $value) {
    if (count($value) == 1) {
      $result[$name] = $value[0];
    }
  }
  return $result;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question