Answer the question
In order to leave comments, you need to log in
How to make navigation in bitrix news detail sorted by active date?
Hello.
My code. I display internal navigation in bitrix news detail.
Modifier:
<?
$res = CIBlockElement::GetList(Array("ID"=>"ASC", "ACTIVE"=>"Y"), Array("IBLOCK_CODE"=>"news", "ACTIVE"=>"Y"), false);
while ($RR = $res->GetNext()) {
if ($RR["ID"] < $arResult["ID"]) {
$prev = $RR["DETAIL_PAGE_URL"];
}
if ($RR["ID"] > $arResult["ID"]) {
$next = $RR["DETAIL_PAGE_URL"];
break;
}
}
$arResult["PREV_LINK"] = $prev;
$arResult["NEXT_LINK"] = $next;
?>
<table class="news_nav" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="prev_news"><?if(!empty($arResult["PREV_LINK"])):?><a href="<?=$arResult["PREV_LINK"]?>">Предыдущая новость</a><?endif?></td>
<td class="all_news"><a href="/news/">Все новости</a></td>
<td class="next_news"><?if(!empty($arResult["NEXT_LINK"])):?><a href="<?=$arResult["NEXT_LINK"]?>">Следующая новость</a><?endif?></td>
</tr>
</table>
Answer the question
In order to leave comments, you need to log in
Your sorting is "ACTIVE"=>"Y"
Read this - https://dev.1c-bitrix.ru/api_help/iblock/classes/c...
The active date field is "DATE_ACTIVE_FROM"
$res = CIBlockElement::GetList(
Array(
'DATE_ACTIVE_FROM' => 'ASC'
),
Array("IBLOCK_CODE"=>"news", "ACTIVE"=>"Y"),
false,
false,
[ указывайте, какие поля читать.
Не тяните целую колбасу, когда вам нужно всего пару полей
]
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question