Last active
August 7, 2017 12:05
-
-
Save geff21st/7f95dff3e259fd547e77e94680751b4f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$arFilter = array("IBLOCK_ID" => $arResult["IBLOCK_ID"], "ACTIVE" => "Y"); | |
if (!empty($arResult["IBLOCK_SECTION_ID"])) { | |
$arFilter["IBLOCK_SECTION_ID"] = $arResult["IBLOCK_SECTION_ID"]; | |
} | |
$resNav = CIBlockElement::GetList( | |
array( | |
$arParams['SORT_BY1'] => $arParams['SORT_ORDER1'], | |
$arParams['SORT_BY2'] => $arParams['SORT_ORDER2'], | |
), | |
$arFilter, | |
false, | |
array("nPageSize" => 1, "nElementID" => $arResult["ID"]), | |
array("ID", "DETAIL_PAGE_URL", "NAME") | |
); | |
$arNav = array(); | |
while ($item = $resNav->GetNext()) { | |
$arNav[] = $item; | |
} | |
if (count($arNav) > 2) { | |
$arResult["NEXT"] = $arNav[0]; | |
$arResult["PREV"] = $arNav[2]; | |
} else { | |
if ($arNav[0]["ID"] == $arResult["ID"]) { | |
$arResult["NEXT"] = false; | |
$arResult["PREV"] = $arNav[1]; | |
} else { | |
$arResult["NEXT"] = $arNav[0]; | |
$arResult["PREV"] = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment