Answer the question
In order to leave comments, you need to log in
How to display bitrix infoblock elements to build a slider?
Please help me combine the code to display the slider
I get a list of elements
<?
if (CModule::IncludeModule("iblock")):
// ID инфоблока из которого выводим элементы
$iblock_id = 26;
$my_slider = CIBlockElement::GetList (
// Сортировка элементов
Array("ID" => "ASC"),
Array("IBLOCK_ID" => $iblock_id),
false,
false,
// Перечисляесм все свойства элементов, которые планируем выводить
Array(
'ID',
'NAME',
'PREVIEW_PICTURE',
'PREVIEW_TEXT',
'PROPERTY_LIN_PR'
)
$limit = 10; // Amount of images to show
$i = 0;
$j = 0;
foreach ( $result->data as $post )
{
if ( $i < $limit ){
$i++;
if(($i == 1) || ($i == 4)){?>
<div class="col-xs-12 col-sm-3 default">
<div class="image-wrapper">
<a href="<?=$link->link?>" target="_blank" class="image" style="background: url(<?=$img?>) no-repeat;"></a>
</div>
</div>
<?}
if($i == 2) {?>
<div class="col-xs-12 col-sm-2 default">
<div class="row no-gutters h50">
<div class="col-xs-12 col-sm-12">
<div class="image-wrapper">
<a href="<?=$link->link?>" target="_blank" class="image" style="background: url(<?=$img?>) no-repeat;"></a>
</div>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
What is the problem? The fact that there is no suitable ready-made code?
foreach ($my_slider as $row) {
$name = $row['NAME'];
$previewSrc = $row['PREVIEW_PICTURE'] ? CFile::getPath($row['PREVIEW_PICTURE']) : null;
$previewText = $row['PREVIEW_TEXT'];
$linPrValue = $row['PROPERTY_LIN_PR_VALUE'];
// code ...
}
Make it easier. you take the news list component and create your own template for it by copying and changing the default one. In $arResult in the template, you will already have all the pictures with ordering, taking into account sorting. js and css add to taste.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question