: 09.09.2013 19:57:13 | : 06.11.2016 17:40:25 | : 2650

, . «Latest News» - . . : , , ( , , ).

, , (bitrix:news.list). . .

. : , .

. .

(main). last_article. FTP.

(_/bitrix/templates/main/components/bitrix/news.list/last_article). template.php. . :

<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>

<?
$arSelect = Array("ID", "NAME", "ACTIVE_FROM", "TIMESTAMP_X", "PREVIEW_TEXT", "DETAIL_PAGE_URL");
$arOrder = Array("created"=>"DESC");
$arFilter = Array("IBLOCK_ID"=> 2);
$rsRes = CIBlockElement::GetList($arOrder, $arFilter, false, Array("nTopCount"=>1), $arSelect);
$arItems = array();
while($arItem = $rsRes->GetNext())
{
	$arItems[] = $arItem;
	$arItems["DATE_FORMAT"] = ParseDateTime($arItem["DATE_CREATE"], FORMAT_DATETIME);
	$arItems["EDITED_FORMAT"] = ParseDateTime($arItem["TIMESTAMP_X"], FORMAT_DATETIME);
	
}
$date = sprintf("%1d", intval($arItems["DATE_FORMAT"]["DD"]))." ".ToLower(GetMessage("MONTH_".intval($arItems["DATE_FORMAT"]["MM"])."_S"))." ".$arItems["DATE_FORMAT"]["YYYY"]."  ".
		$arItems["DATE_FORMAT"]["HH"].":".$arItems["DATE_FORMAT"]["MI"].":".$arItems["DATE_FORMAT"]["SS"];
$edited = sprintf("%1d", intval($arItems["EDITED_FORMAT"]["DD"]))." ".ToLower(GetMessage("MONTH_".intval($arItems["EDITED_FORMAT"]["MM"])."_S"))." ".$arItems["EDITED_FORMAT"]["YYYY"]."  ".
		$arItems["EDITED_FORMAT"]["HH"].":".$arItems["EDITED_FORMAT"]["MI"].":".$arItems["EDITED_FORMAT"]["SS"];

?>
<div class="sidebar">
  <h3></h3>
  <h4><?=$arItems[0]["NAME"]?></h4>
  <h5>: <br><?=$date?></h5>
  <h5>: <br><?=$edited?></h5>
  <p><?=substr($arItems[0]["PREVIEW_TEXT"],0,100)."..."?><br /><a href="<?=$arItems[0]["DETAIL_PAGE_URL"]?>" title=""></a></p>
</div>

.

<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?> . , B_PROLOG_INCLUDED. , .

3 ($arSelect, $arOrder, $arFilter) . $arResult, ( component.php). : ID , , ( ), , . . , (DESC). ID (2). , ID .

$arItems , . GetList CIBlockElement ( ). <div class="sidebar"> </div>, .

template.php . .

. header.php . <div> sidebar. sidebar .

3.jpg

- URL . .

. ( –軠). URL . : #SITE_DIR#//articles/?ELEMENT_ID=#ELEMENT_ID#. . , .