C
C
countZer02020-07-10 10:30:59
1C-Bitrix
countZer0, 2020-07-10 10:30:59

How to display items in order using getlist?

Hello !

Tell me how to display elements through CIBlockElement::GetList, so that the elements are displayed 50 per page, but when the page is reloaded, the next 50 elements are displayed

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2020-07-10
@countZer0

but when reloading the page, the following 50 items were displayed

what does it mean? You do understand that in order for the request to produce something else, something must change in it? For example, a parameter in GET (as is actually done in Bitrix, the parameter ?PAGEN_1=2) or do you have some kind of increment in the cookie, what determines the display of the next 50 elements?
In general, the request will look like this
\Bitrix\Main\Loader::includeModule('iblock');

$iblockId = 2;
$nPageSize = 50;
$iNumPage = 1;

$arElements = array();
$dbRes = CIBlockElement::GetList(array('ID' => 'ASC'), array('IBLOCK_ID' => $iblockId), false, array('nPageSize' => $nPageSize, 'iNumPage' => $iNumPage), array('ID', 'NAME'));

while($arRes = $dbRes->Fetch()) {
  $arElements[] = $arRes;
}

echo '<pre>';
print_r($arElements);
echo '</pre>';

Increment $iNumPage and you will get a shift of $nPageSize records

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question