Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions GetList
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
class GetList
{
function GetCachedElements($Filter, $arSelect = false, $sort = Array("NAME" => "ASC"), $pageParams = false)
{
if (!CModule::IncludeModule("iblock")) return false;
if (empty($Filter)) return false;
$arResult = false;
$obCache = new CPHPCache;
$life_time = 3600;
$cache_params = $Filter;
$cache_params['func'] = 'CIBlockElement::GetList';
$cache_params['arSelect'] = $arSelect;
$cache_params['sort'] = $sort;
$cache_params['pageParams'] = $pageParams;
$cache_id = md5(serialize($cache_params));
if ($obCache->InitCache($life_time, $cache_id, "/")) :
$arResult = $obCache->GetVars();
else :
$ElList = CIBlockElement::GetList($sort, $Filter, false, $pageParams, $arSelect);
while ($arElement = $ElList->GetNext()) {
$arResult[] = $arElement;
}
endif;
if ($obCache->StartDataCache()):
$obCache->EndDataCache($arResult);
endif;
return $arResult;
}
}
20 changes: 20 additions & 0 deletions getLastNews.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php');
?>
<?
if(!CModule::IncludeModule("iblock"))
{
ShowError(GetMessage("IBLOCK_MODULE_NOT_INSTALLED"));
return;
}
$arRes = CIBlockRSS::GetNewsEx("www.lenta.ru", 80, "/rss/", 'LIMIT=3', false);
$arRes = CIBlockRSS::FormatArray($arRes, 'N');
while(count($arRes["item"])>5){
array_pop($arRes["item"]);
}
array_walk_recursive($arRes, create_function('&$val, $key', '$val=htmlspecialcharsex($val);'));
//array_walk_recursive($arRes, create_function('&$val, $key', '$val=str_replace(array(" ", "\\r\\n"), array("&nbsp;&nbsp;&nbsp;&nbsp;", "<br>"), HTMLToTxt($val));'));
foreach($arRes["item"] as $i=> $item){
echo '<p>'.$i.'.'.$item['title'].'<br>'.$item['link'].'<br>'.$item['description'].'</p><br>';
}
?>