A
A
Anton2021-06-03 08:10:20
1C-Bitrix
Anton, 2021-06-03 08:10:20

How to add links to partners?

On the main page there is a withdrawal of partners, there are 5 pictures, how to make a link for each, that is, by clicking on the picture to transfer it to the partner’s website?

Partner withdrawal code

<div class="container-custom">
    <div class="owl-carousel partners-carousel owl-theme">
      <?

      $IBLOCK_ID = 6;
      $arSelect = array("ID", "IBLOCK_ID", "NAME", "DATE_ACTIVE_FROM", "PROPERTY_*", "PREVIEW_PICTURE");
      $arFilter = array("IBLOCK_ID" => $IBLOCK_ID, "ACTIVE_DATE" => "Y", "ACTIVE" => "Y");
      $res = CIBlockElement::GetList(array('SORT' => 'ASC'), $arFilter, false, false, $arSelect);
      while ($ob = $res->GetNextElement()) {
        $arFields = $ob->GetFields();
        $arProps = $ob->GetProperties();
        $img = CFile::GetPath($arFields['PREVIEW_PICTURE']);

      ?>
        <div class="carousel__item">
          <img class="carosel__img" src="<?= $img ?>" alt="">
        </div>
      <?
      }
      ?>
    </div>
  </div>


In my admin
60b8642ce45d5707716851.png
60b86432f1d41661774584.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton, 2021-06-07
Websaytovsky @ws17

Catch the solution:

<?

      $IBLOCK_ID = 6;
      $arSelect = array("ID", "IBLOCK_ID", "NAME", "url", "DATE_ACTIVE_FROM", "PROPERTY_*", "PREVIEW_PICTURE");
      $arFilter = array("IBLOCK_ID" => $IBLOCK_ID, "ACTIVE_DATE" => "Y", "ACTIVE" => "Y");
      $res = CIBlockElement::GetList(array('SORT' => 'ASC'), $arFilter, false, false, $arSelect);
      while ($ob = $res->GetNextElement()) {
        $arFields = $ob->GetFields();
        $arProps = $ob->GetProperties();
        $img = CFile::GetPath($arFields['PREVIEW_PICTURE']);
        $arPrp = array_column($arProps, null, 'NAME');
      ?>
        <div class="carousel__item">
          <a href="<? echo $arPrp["url"]['VALUE']; ?>">
            <img class="carosel__img" src="<?= $img ?>" alt="">
          </a>
        </div>
      <?
      }
      ?>

A
Alexander, 2021-06-03
@kikher

like who so

<a href="<?=$arFields['DETAIL_PAGE_URL']?>"><img class="carosel__img" src="<?= $img ?>" alt=""></a>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question