V
V
Viktor Dotsenko2014-07-25 15:13:58
PHP
Viktor Dotsenko, 2014-07-25 15:13:58

How to get image path from custom element in Bitrix?

There is an infoblock for example with Id (14), inside I created a custom field "SLIEDER_FOTO" of type "file" property id 183.
I want to get the path to this image.
According to the idea, they are extracted into the $ar_fields array and can be accessed - $ar_fields['PROPERTY_DOCS_VALUE'] only displays through checked -


Array
(
[0] => 4572
[1] => 4573
[2] => 4574
)

OK. I'm trying to loop through:
foreach($ar_fields['PROPERTY_SLIEDER_FOTO'] as $pic):
          $arFile = CFile::GetFileArray($pic);
          //print_r($arFile);
          //$name = substr($arFile['FILE_NAME'], 0, -4);
          echo '<p><img"'.$arFile['SRC'].'"></p>';
        endforeach;

The result - alas, no. Guys, how to get data from this array?
data fetch code:
$APPLICATION->AddChainItem('Таунхаусы','/townhouses');
$arFilter = Array(
    "IBLOCK_ID"=>14,
    "ACTIVE"=>"Y",
    "CODE"=>$_REQUEST['ID']
);
$res = CIBlockElement::GetList(Array("ID"=>"ASC"), $arFilter,false,false,Array("ID","CODE","NAME","PREVIEW_PICTURE","PROPERTY_NAPRAVLENIE_VALUE","PROPERTY_COMMUNICATIONS","PROPERTY_TIME","PROPERTY_MKAD","PROPERTY_AREA_1","PROPERTY_AREA_2","PROPERTY_PRICE_MIN","PROPERTY_PRICE_MAX","DETAIL_TEXT","PROPERTY_DOCS","PROPERTY_NEWS","PROPERTY_MAP","PROPERTY_PHOTO","PROPERTY_SPEC_OFFER","PROPERTY_LOGO","PROPERTY_MANAGER","PROPERTY_CREDIT","PROPERTY_GENPLAN","PROPERTY_SLIEDER_FOTO"));
if($ar_fields = $res->GetNext()){
  $APPLICATION->AddChainItem($ar_fields['NAME'],'/townhouses/'.$_REQUEST['ID']);
  $APPLICATION->AddChainItem('Генплан');
  $APPLICATION->SetTitle('Генплан '.$ar_fields['NAME']);
  global $NAMEPROJ,$LOGOS,$MANAGER;
  $NAMEPROJ=$ar_fields['NAME'];
  $MANAGER=$ar_fields['PROPERTY_MANAGER_VALUE'];
  $LOGOS=$ar_fields['PROPERTY_LOGO_VALUE'];

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Skahin, 2014-07-25
@V1rTu

dev.1c-bitrix.ru/api_help/main/reference/cfile/get...

I
Ilya Petrovsky, 2014-07-28
@Mpa3b_ru21

dump the array via print_r - you'll see.
try $ar_fields['PROPERTY_DOCS_DISPLAY_VALUE']
it's strange that you don't have data in the field, but it's not clear why the id...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question