S
S
sagaton2022-04-11 11:03:03
1C-Bitrix
sagaton, 2022-04-11 11:03:03

How to display additional photos in the detailed description of the product?

Everyone loves the day.
There is such a code

<div class="item-card__slider">
            <div class="swiper-container gallery-top">
                <div class="swiper-wrapper">
                    <?foreach($arResult['MORE_PHOTO'] as $key => $img):?>
                        <?$img_resize_path = CFile::ResizeImageGet(
                            $arResult[PROPERTIES][MORE_PHOTO][VALUE][0],
                            BX_RESIZE_IMAGE_PROPORTIONAL
                        );
                        ?>
                        <div class="swiper-slide">
                            <img alt="" src="<?=$img_resize_path['src']?>"/>
                        </div>
                    <? endforeach?>

                </div>
            </div>
            <div class="swiper-container gallery-thumbs">
                <div class="swiper-wrapper">
                        <?foreach($arResult['MORE_PHOTO'] as $key => $img):?>
                            <?$img_resize_path = CFile::ResizeImageGet(
                                $arResult[PROPERTIES][MORE_PHOTO][VALUE][0],
                                BX_RESIZE_IMAGE_PROPORTIONAL
                            );
                            ?>
                            <div class="swiper-slide">
                                <img alt="" src="<?=$img_resize_path['src']?>"/>
                            </div>
                        <? endforeach?>
                    </div>
            </div>
            <div class="swiper-pagination"></div>
            <div class="swiper-button-next"></div>
            <div class="swiper-button-prev"></div>
        </div>


It displays the same picture and additional photos.
In add. photo I have 3 of them and displays 3 identical photos.
As soon as I did not try to go through the keys through the loop, but nothing worked. either one and also a picture or nothing at all.
Tell me how it would be possible to display all 3 pictures from the add. a photo.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Olga, 2022-04-11
@sagaton

there are several errors here:

  1. you go through $arResult['MORE_PHOTO'] with foreach and as a result you don't use variables ($key,$img), $arResult[PROPERTIES][MORE_PHOTO][VALUE][0] - you always take the null element, the result is obvious, so read about cycles and learn how to use them
  2. judging by the fact that at least something is displayed, you need to go through not $arResult['MORE_PHOTO'], but $arResult['PROPERTIES']['MORE_PHOTO']['VALUE']
  3. $arResult[PROPERTIES][MORE_PHOTO][VALUE][0] - the keys do not have quotes, but these are strings, not constants, even though the interpreter will gobble up - this is not good to do.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question