<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$APPLICATION->SetTitle("Добро пожаловать");
?>
<?
$IBLOCK = Ваш инфоблок;
if($_REQUEST['ID']>0)
{
$NEWS = _getById($_REQUEST['ID']);
echo $NEWS['DATE_CREATE'].' '.$NEWS['NAME'].'<br /><br />'.$NEWS['DETAIL_TEXT'];
}
else
{
$res = _GetList($IBLOCK);
$list = array();
while($row = $res->GetNext())
$list[substr($row['DATE_CREATE'],6,4)][] = $row;
foreach($list as $key=>$row)
{
echo $key.'<br />';
foreach($row as $news)
echo '---<a href="?ID='.$news['ID'].'">'.$news['NAME'].'</a><br />';
}
echo '<br /><br />';
$res->NavPrint($arIBTYPE["SECTION_NAME"]);
}
function _GetList($IBLOCK)
{
$select = array('ID','NAME','DATE_CREATE');
$filters = Array('IBLOCK_ID'=>$IBLOCK);
if($IBLOCK>0)
return CIBlockElement::GetList(Array('DATE_CREATE'=>'DESC'), $filters, false, Array("nPageSize"=>25), $select);
else
return false;
}
function _getById($ID)
{
GLOBAL $IBLOCK;
$select = array('ID','NAME','DATE_CREATE','PREVIEW_TEXT','DETAIL_TEXT');
$filters = Array('IBLOCK_ID'=>$IBLOCK);
$res = CIBlockElement::GetList(false, $filters, false, false, $select);
return $row = $res->GetNext();
}
?>
<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>
|