Created
July 8, 2018 21:10
-
-
Save gdecider/fb4fd46598a42af7461f5afa22446dc7 to your computer and use it in GitHub Desktop.
Битрикс Ш постраничная навигация
This file contains 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
<? if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die(); | |
/** @var array $arParams */ | |
/** @var array $arResult */ | |
/** @global CMain $APPLICATION */ | |
/** @global CUser $USER */ | |
/** @global CDatabase $DB */ | |
/** @var CBitrixComponentTemplate $this */ | |
/** @var string $templateName */ | |
/** @var string $templateFile */ | |
/** @var string $templateFolder */ | |
/** @var string $componentPath */ | |
/** @var CBitrixComponent $component */ | |
$this->setFrameMode(true); | |
if(!$arResult["NavShowAlways"]) { | |
if ($arResult["NavRecordCount"] == 0 || ($arResult["NavPageCount"] == 1 && $arResult["NavShowAll"] == false)) { | |
return; | |
} | |
} | |
$strNavQueryString = ($arResult["NavQueryString"] != "" ? $arResult["NavQueryString"]."&" : ""); | |
$strNavQueryStringFull = ($arResult["NavQueryString"] != "" ? "?".$arResult["NavQueryString"] : ""); | |
$arResult["nStartPage"] = 1; | |
$arResult["nEndPage"] = $arResult["NavPageCount"]; | |
$sPrevHref = ''; | |
if ($arResult["NavPageNomer"] > 1) { | |
$bPrevDisabled = false; | |
if ($arResult["bSavePage"] || $arResult["NavPageNomer"] > 2) { | |
$sPrevHref = $arResult["sUrlPath"].'?'.$strNavQueryString.'PAGEN_'.$arResult["NavNum"].'='.($arResult["NavPageNomer"]-1); | |
} else { | |
$sPrevHref = $arResult["sUrlPath"].$strNavQueryStringFull; | |
} | |
} else { | |
$bPrevDisabled = true; | |
} | |
$sNextHref = ''; | |
if ($arResult["NavPageNomer"] < $arResult["NavPageCount"]) { | |
$bNextDisabled = false; | |
$sNextHref = $arResult["sUrlPath"].'?'.$strNavQueryString.'PAGEN_'.$arResult["NavNum"].'='.($arResult["NavPageNomer"]+1); | |
} else { | |
$bNextDisabled = true; | |
} | |
?> | |
<?// общая информация ?> | |
<?=$arParams["NAV_TITLE"]?> <?=$arResult["NavFirstRecordShow"]?> — <?=$arResult["NavLastRecordShow"]?> из <?=$arResult["NavRecordCount"]?> | |
<?// вывод навигации ?> | |
<ul> | |
<li><a href="<?echo $bPrevDisabled ? '#' : $sPrevHref?>">Пред.</a></li> | |
<? | |
$bFirst = true; | |
$bPoints = false; | |
do { | |
if ($arResult["nStartPage"] <= 2 || $arResult["nEndPage"]-$arResult["nStartPage"] <= 1 || abs($arResult['nStartPage']-$arResult["NavPageNomer"])<=2) { | |
if ($arResult["nStartPage"] == $arResult["NavPageNomer"]):?> | |
<li class="active"><?=$arResult["nStartPage"]?></li> | |
<? | |
elseif($arResult["nStartPage"] == 1 && $arResult["bSavePage"] == false):?> | |
<li><a href="<?=$arResult["sUrlPath"]?><?=$strNavQueryStringFull?>"><?=$arResult["nStartPage"]?></a></li> | |
<?else:?> | |
<li><a href="<?=$arResult["sUrlPath"]?>?<?=$strNavQueryString?>PAGEN_<?=$arResult["NavNum"]?>=<?=$arResult["nStartPage"]?>"><?=$arResult["nStartPage"]?></a></li> | |
<?endif; | |
$bFirst = false; | |
$bPoints = true; | |
} else { | |
if ($bPoints) { | |
?><li>...</li><? | |
$bPoints = false; | |
} | |
} | |
$arResult["nStartPage"]++; | |
} while($arResult["nStartPage"] <= $arResult["nEndPage"]);?> | |
<li><a href="<?echo $bNextDisabled ? '#' : $sNextHref?>">След.</a></li> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment