D
D
Darklt2016-11-01 15:58:12
PHP
Darklt, 2016-11-01 15:58:12

How to display 2 $arItem['ID'] Bitrix in news?

There is a slider connected to the template bitrix.news.
Tell me how to make it so that 2 elements are displayed in one slide, that is, in the first 1.2 in the second 3.4, etc.

<div class="slider">
        <ul class="slides">
<?foreach($arResult["ITEMS"] as $arItem):?>
  <?
  $this->AddEditAction($arItem['ID'], $arItem['EDIT_LINK'], CIBlock::GetArrayByID($arItem["IBLOCK_ID"], "ELEMENT_EDIT"));
  $this->AddDeleteAction($arItem['ID'], $arItem['DELETE_LINK'], CIBlock::GetArrayByID($arItem["IBLOCK_ID"], "ELEMENT_DELETE"), array("CONFIRM" => GetMessage('CT_BNL_ELEMENT_DELETE_CONFIRM')));
  ?>

  <li class="slide news-item" id="<?=$this->GetEditAreaId($arItem['ID']);?>">
    <a href="<?echo $arItem["DETAIL_PAGE_URL"]?>"><b><?echo $arItem["NAME"]?></b></a><br />
      <?echo $arItem["PREVIEW_TEXT"];?>
  </li>
  
<?endforeach;?></ul>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bx-coder, 2016-11-01
@bx-coder

<ul class="slides">
  <?
  $arItemsChunks = array_chunk($arResult["ITEMS"], 2, true);
  foreach($arItemsChunks as $arChunk):?>
    <li class="slide news-item">
      <?foreach($arChunk as $key => $arItem):?>
        <?
        $this->AddEditAction($arItem['ID'], $arItem['EDIT_LINK'], CIBlock::GetArrayByID($arItem["IBLOCK_ID"], "ELEMENT_EDIT"));
        $this->AddDeleteAction($arItem['ID'], $arItem['DELETE_LINK'], CIBlock::GetArrayByID($arItem["IBLOCK_ID"], "ELEMENT_DELETE"), array("CONFIRM" => GetMessage('CT_BNL_ELEMENT_DELETE_CONFIRM')));
        ?>
        <a href="<?echo $arItem["DETAIL_PAGE_URL"]?>"><b><?echo $arItem["NAME"]?></b></a><br />
        <?echo $arItem["PREVIEW_TEXT"];?>
      <?endforeach;?>
    </li>
  <?endforeach;?>
</ul>

Try like this. The link and text can be wrapped in a container and given an id so that it can be edited in edit mode.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question