постраничка

Bitrix постраничка для массива 2

17.12.2013 Bitrix ,

/* 
 component params
*/
"NEWS_COUNT" => "2",
"PAGER_TITLE" => "", 
"PAGER_SHOW_ALWAYS" => "N", 
"PAGER_TEMPLATE" => "", 
"PAGER_DESC_NUMBERING" => "N", 
"PAGER_DESC_NUMBERING_CACHE_TIME" => "36000", 
"PAGER_SHOW_ALL" => "Y",


/* 
 component
*/
$rs = new CDBResult;
$rs->InitFromArray($arResult["ITEMS"]);
$rs->NavStart($arParams["NEWS_COUNT"]);

$arResult["NAV_STRING"] = $rs->GetPageNavStringEx($navComponentObject, $arParams["PAGER_TITLE"], $arParams["PAGER_TEMPLATE"], $arParams["PAGER_SHOW_ALWAYS"]);
$arResult["NAV_CACHED_DATA"] = $navComponentObject->GetTemplateCachedData();
$arResult["NAV_RESULT"] = $rs;

$arResult["ITEMS"] = array();
while($arSection = $rs->Fetch()){
 $arResult["ITEMS"][] = $arSection;
}


/*
 template
*/
<?if($arParams["DISPLAY_BOTTOM_PAGER"]):>
 <?=$arResult["NAV_STRING"]?>
<?endif;?>

Bitrix постраничка для массива

29.08.2012 Bitrix No comments ,

$arr = array();
$arr[] = array("ID" => 1, "NAME" => "Заголовок 1");
$arr[] = array("ID" => 2, "NAME" => "Заголовок 2");
$arr[] = array("ID" => 3, "NAME" => "Заголовок 3");
$arr[] = array("ID" => 4, "NAME" => "Заголовок 4");

$rs = new CDBResult;
$rs->InitFromArray($arr);

$rs->NavStart(2);
if($rs->IsNavPrint())
{
     echo "<p>"; $rs->NavPrint("Элементы"); echo "</p>";
}
while($test = $rs->Fetch()){
	print_r($test);
}