2022-11-24 08:39:31 +03:00

40 lines
1.1 KiB
PHP

<?
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
/** @var CBitrixComponent $this */
/** @var array $arParams */
/** @var array $arResult */
/** @var string $componentPath */
/** @var string $componentName */
/** @var string $componentTemplate */
/** @global CDatabase $DB */
/** @global CUser $USER */
/** @global CMain $APPLICATION */
use Bitrix\Main\Context,
Bitrix\Main\Type\DateTime,
Bitrix\Main\Loader,
Bitrix\Iblock;
if($this->StartResultCache(60*60*24, md5(var_export($_POST, true))))
{
if(CModule::IncludeModule('iblock'))
{
$filter = ["ACTIVE" => "Y", "IBLOCK_ID" => IBLOCK_ID_BANNERS_INNER];
$banner_res = CIBlockElement::GetList(["RAND" => "ASC", ], $filter, false, [ "nPageSize" => 1 ]);
while ($banner_ob_element = $banner_res->GetNextElement())
{
$banner_ar_res = $banner_ob_element->GetFields();
$banner_ar_res['PROPERTIES'] = $banner_ob_element->GetProperties();
if(isset($banner_ar_res['PREVIEW_PICTURE']))
{
$banner_ar_res['PREVIEW_PICTURE'] = CFile::GetPath($banner_ar_res['PREVIEW_PICTURE']);
}
$arResult['BANNER'] = $banner_ar_res;
}
$this->IncludeComponentTemplate();
}
}