Answer the question
In order to leave comments, you need to log in
Bitrix. Multiple file and fancybox. How to remove looping?
The property is multiple, uploading a video/photo.
If the element is 1 - when there is a loop and it is duplicated 12 times
But if I add the second element - the full order, 2 is displayed, as it should be.
Here is a screenshot, although it only has 1 image loaded.
What could be the problem?
Piece of code:
<?if(!empty($arResult["PROPERTIES"]["OBJ_VIDEO"]["~VALUE"])):?>
<div class="video">
<h3>Видео</h3>
<div class="gallery">
<?foreach($arResult[DISPLAY_PROPERTIES][OBJ_VIDEO][FILE_VALUE] as $arVideo):?>
<div class="object">
<a data-fancybox="gallery" class="gallery" href="<?=($arVideo[SRC]);?>"><img src="<?php echo SITE_TEMPLATE_PATH ?>/img/video.png" alt=""></a>
</div>
<?endforeach;?>
</div>
</div>
<? endif ?>
Answer the question
In order to leave comments, you need to log in
Option 1
You are using the gallery tag, perhaps the fact is that you have a slider library connected and it has something like loop, it often does not work correctly when there is 1 element.
Option 2
Make a check possibly return not an array, but a string when 1 element
echo "<pre>";
print_r($arResult["DISPLAY_PROPERTIES"]["OBJ_VIDEO"]);
echo "</pre>";
Andrew, thank you very much for your reply!
But really, maybe there is a loop there and he understands 2 elements how to loop, but one does not?
Here is the test result:
Array
(
[ID] => 18
[TIMESTAMP_X] => 2019-04-21 01:53:52
[IBLOCK_ID] => 1
[NAME] => Видео объекта
[ACTIVE] => Y
[SORT] => 630
[CODE] => OBJ_VIDEO
[DEFAULT_VALUE] =>
[PROPERTY_TYPE] => F
[ROW_COUNT] => 1
[COL_COUNT] => 30
[LIST_TYPE] => L
[MULTIPLE] => Y
[XML_ID] =>
[FILE_TYPE] =>
[MULTIPLE_CNT] => 5
[TMP_ID] =>
[LINK_IBLOCK_ID] => 0
[WITH_DESCRIPTION] => N
[SEARCHABLE] => N
[FILTRABLE] => N
[IS_REQUIRED] => N
[VERSION] => 1
[USER_TYPE] =>
[USER_TYPE_SETTINGS] =>
[HINT] =>
[PROPERTY_VALUE_ID] => Array
(
[0] => 471
)
[VALUE] => Array
(
[0] => 501
)
[DESCRIPTION] => Array
(
[0] =>
)
[VALUE_ENUM] =>
[VALUE_XML_ID] =>
[VALUE_SORT] =>
[~VALUE] => Array
(
[0] => 501
)
[~DESCRIPTION] => Array
(
[0] =>
)
[~NAME] => Видео объекта
[~DEFAULT_VALUE] =>
[DISPLAY_VALUE] => Загрузить
[FILE_VALUE] => Array
(
[ID] => 501
[TIMESTAMP_X] => 23.04.2019 20:54:16
[MODULE_ID] => iblock
[HEIGHT] => 0
[WIDTH] => 0
[FILE_SIZE] => 11069444
[CONTENT_TYPE] => video/mp4
[SUBDIR] => iblock/526
[FILE_NAME] => 52627d2bccc84b0b2f9c7da5f2263cc3.mp4
[ORIGINAL_NAME] => IMG_0363.mp4.mp4
[DESCRIPTION] =>
[HANDLER_ID] =>
[EXTERNAL_ID] => f40652ee0fced61e16f6ba9fa1e022a4
[~src] =>
[SRC] => /upload/iblock/526/52627d2bccc84b0b2f9c7da5f2263cc3.mp4
)
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question