Answer the question
In order to leave comments, you need to log in
Bitrix, how to set a custom amount of news for pagination?
There is a news page, on it initially (on 1 page it turns out) 4 news are displayed (design features, 3 columns + 1 news in full width), then using ajax I load 6 news each. (2 rows x 3 columns).
But in this scenario, 2 news are lost, since the second page is obtained from the 7th news.
How can I adjust the values so that in the pagination, when calculating the indexes of the news that you want to display on this page, an adjustment for -2 indexes is applied? and instead of from 7 to 12 they took from 5 to 10?
Answer the question
In order to leave comments, you need to log in
Standard news.list is not a solution,
you can write your own component. here is the base:
CModule::IncludeModule("iblock");
$arSelect = [
'ID',
'NAME',
];
$arFilter = [
'IBLOCK_CODE' => 'news',
];
if ($_REQUEST['PAGEN_1'] > 1) {
$arNavStartParams = [
'iNumPage' => $_REQUEST['PAGEN_1'] - 1,
'nPageSize' => 6,
];
$arFilter['!ID'] = [1, 2, 3, 4]; // TODO: получить эти данные в запросе и закешировать
} else {
$arNavStartParams = [
'nTopCount' => 0,
'iNumPage' => 1,
'nPageSize' => 10,
];
}
$obFields = CIBlockElement::GetList(
['ID' => 'asc'],
$arFilter,
false,
$arNavStartParams,
$arSelect
);
$arCurrentData = [];
while($arField = $obFields->Fetch()) {
print_r($arField);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question