I
I
IgorRastarov2017-01-11 12:03:01
PHP
IgorRastarov, 2017-01-11 12:03:01

How to display a property via GetList in Bitrks?

I need to pull the MORE_PHOTO property.
Here is a piece of code in catalog.section.list

$arSelect = array(
  'PROPERTY_MORE_PHOTO',
  'PREVIEW_PICTURE',
  'DETAIL_PICTURE',
  );

    foreach ($arResult["SECTIONS"] as &$arSection) {
        $rsPhotoElements = CIBlockElement::GetList(array("SORT" => "ASC", "NAME" => "ASC"), 
        array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "SECTION_ID" => $arSection["ID"], "ACTIVE" => "Y"),
        false, 
        false, 
        $arSelect);
        $i = 4;
        while ($i && $arElement = $rsPhotoElements->GetNext()) {
            $photo = CFile::ResizeImageGet($arElement["DETAIL_PICTURE"], 
            array('width'=>200, 'height'=>180), 
            BX_RESIZE_IMAGE_PROPORTIONAL);
            $arElement["PREVIEW_PICTURE"] = $photo['src'];
            $arElement["DETAIL_PICTURE"] = CFile::GetFileArray($arElement["DETAIL_PICTURE"]);
      $arElement["PROPERTY_MORE_PHOTO"] = CFile::GetFileArray($arElement["PROPERTY_MORE_PHOTO"]);
            $arSection["ELEMENTS"][] = $arElement;
            $i--;
        }
    }

With the help of the code, a detailed picture, preview, and so on are displayed. The bottom line is that when I do
var_dump($arElement["PREVIEW_PICTURE"]);
it, it displays the line string(55) "/upload/iblock/da4/da49c59a517fc02b40ed6cf5780efd24.png" - this is the path to one of the previews.
var_dump($arElement["PROPERTY_MORE_PHOTO"]);
it outputs bool(false) line.
How can I make it show me "PROPERTY_MORE_PHOTO" so that I can see it?
Why does it output that it is empty?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
Oleg Maksimenko, 2017-01-11
@olegprof

var_dump($arElement["PROPERTY_MORE_PHOTO_VALUE"]);

I
IgorRastarov, 2017-01-11
@IgorRastarov

In general, I did like this in modifire

$arSelect = array(
  'PROPERTY_MORE_PHOTO',
  'PREVIEW_PICTURE',
  'DETAIL_PICTURE',
  );

    foreach ($arResult["SECTIONS"] as &$arSection) {
        $rsPhotoElements = CIBlockElement::GetList(array("SORT" => "ASC", "NAME" => "ASC"), 
array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "SECTION_ID" => $arSection["ID"], "ACTIVE" => "Y"),
 false, 
false,
 $arSelect);
        $i = 4;
        while ($i && $arElement = $rsPhotoElements->GetNext()) {
            $photo = CFile::ResizeImageGet($arElement["DETAIL_PICTURE"],
 array('width'=>200, 'height'=>180), BX_RESIZE_IMAGE_PROPORTIONAL);
            $arElement["PREVIEW_PICTURE"] = $photo['src'];
            $arElement["DETAIL_PICTURE"] = CFile::GetFileArray($arElement["DETAIL_PICTURE"]);
      $arElement["PROPERTY_MORE_PHOTO"] = CFile::GetFileArray($arElement["PROPERTY_MORE_PHOTO"]);
            $arSection["ELEMENTS"][] = $arElement;
            $i--;
        }
    }

And in template
<div class = "fancybox_slider" id = "slider_gallery">
<?foreach ($arResult["SECTIONS"] as $arSection) {?>
            <?foreach ($arSection["ELEMENTS"] as $arItem) {?>
      <?=$arItem["PROPERTY_MORE_PHOTO"]?>
            <?}?>
<?}?>			
</div>

pictures are not displayed. I do not know what to do(

D
Danbka, 2017-01-11
@Danbka

The documentation ( dev.1c-bitrix.ru/api_help/iblock/classes/ciblockel... states: " The IBLOCK_ID and ID fields must be used, otherwise it will not work correctly."
You do not have them in $arselect.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question