From e96ccf9b27af57c925614d917618de2c03147512 Mon Sep 17 00:00:00 2001
From: olegnizamovsimbirsoft
<48482893+olegnizamovsimbirsoft@users.noreply.github.com>
Date: Wed, 4 Sep 2019 10:04:38 +0400
Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B5=D1=81=D1=82=D0=BE=D0=B2=D0=BE?=
=?UTF-8?q?=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B4?=
=?UTF-8?q?=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B7=D1=80=D0=B0=D0=B1=D0=BE=D1=82?=
=?UTF-8?q?=D1=87=D0=B8=D0=BA=D0=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CacheCIBlockElement.php | 48 +++++++++++++++++++++++++++++++++++++++++
getLastNews.php | 29 +++++++++++++++++++++++++
test.php | 14 ++++++++++++
3 files changed, 91 insertions(+)
create mode 100644 CacheCIBlockElement.php
create mode 100644 getLastNews.php
create mode 100644 test.php
diff --git a/CacheCIBlockElement.php b/CacheCIBlockElement.php
new file mode 100644
index 0000000..3572127
--- /dev/null
+++ b/CacheCIBlockElement.php
@@ -0,0 +1,48 @@
+ "ASC"], $arFilter = [], $arGroupBy = false, $arNavStartParams = false, $arSelectFields = [])
+ {
+ if (\CModule::IncludeModule("iblock")) {
+ $obCache = new \CPHPCache;
+
+ // Время жизни кэша
+ $lifeTime = 60 * 10;
+ if (!empty($arFilter['IBLOCK_ID'])) {
+ $cacheID = $arFilter['IBLOCK_ID'];
+ } else {
+ $cacheID = "CacheCIBlockElementDefault";
+ }
+
+ if ($obCache->InitCache($lifeTime, $cacheID, "/")) {
+ $vars = $obCache->GetVars();
+ $DbResult = $vars["RESULT_ARRAY"];
+ } else {
+ $DbResult = \CIBlockElement::GetList($arOrder, $arFilter, $arGroupBy, $arNavStartParams, $arSelectFields);
+ }
+ if ($obCache->StartDataCache()) {
+ $obCache->EndDataCache([
+ "RESULT_ARRAY" => $DbResult,
+ ]);
+ }
+ return $DbResult;
+ }
+ return false;
+ }
+
+}
diff --git a/getLastNews.php b/getLastNews.php
new file mode 100644
index 0000000..80d643a
--- /dev/null
+++ b/getLastNews.php
@@ -0,0 +1,29 @@
+channel->item as $item) {
+
+ if ($item->title) {
+ echo 'НАЗВАНИЕ: ' . $item->title . '
' . PHP_EOL;
+ }
+
+ if ($item->link) {
+ echo 'ССЫЛКА НА НОВОСТЬ: ' . '' . $item->link . '
' . PHP_EOL;
+ }
+
+ if ($item->description) {
+ echo 'АНОНС: ' . $item->description . '
' . PHP_EOL;
+ }
+
+ echo '
' . print_r($arFields, 1) . ''; + } +} + +require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php");