Last active
September 29, 2016 07:45
-
-
Save s2ar/084af26538934fb43739af515babac2d to your computer and use it in GitHub Desktop.
bitrix. prev and next link
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
<?php | |
/* | |
$cp = $this->__component; // объект компонента | |
if (is_object($cp)) { | |
$cp->arResult['NAV_RESULT'] = $arResult['NAV_RESULT']; | |
$cp->SetResultCacheKeys(Array('NAV_RESULT')); | |
} | |
*/ | |
$page = $arParams['PATH_URL']; | |
$prevPage = $arResult['NAV_RESULT']->NavPageNomer - 1; | |
$nextPage = $arResult['NAV_RESULT']->NavPageNomer + 1; | |
$NavNum = $arResult['NAV_RESULT']->NavNum; | |
// Сформируем чистый урл | |
$aGetNew = array(); | |
foreach ($_GET as $key => $value) { | |
if($key=='sort') $aGetNew['sort'] = $value; | |
if(stripos($key, 'PAGEN_')===0) $aGetNew[$key] = $value; | |
} | |
if($arResult['NAV_RESULT']->NavPageNomer > 1){ | |
$aGetNew['PAGEN_'.$NavNum] = $prevPage; | |
$prevLink = $page.'?'.http_build_query($aGetNew,'','&'); | |
$APPLICATION->AddHeadString('<link rel="prev" href="http://'.SITE_SERVER_NAME.$prevLink.'">',true); | |
} | |
if($arResult['NAV_RESULT']->NavPageNomer < $arResult['NAV_RESULT']->NavPageCount){ | |
$aGetNew['PAGEN_'.$NavNum] = $nextPage; | |
$nextLink = $page.'?'.http_build_query($aGetNew,'','&'); | |
$APPLICATION->AddHeadString('<link rel="next" href="http://'.SITE_SERVER_NAME.$nextLink.'">',true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment