Skip to content

Instantly share code, notes, and snippets.

@s2ar
Last active September 29, 2016 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s2ar/084af26538934fb43739af515babac2d to your computer and use it in GitHub Desktop.
Save s2ar/084af26538934fb43739af515babac2d to your computer and use it in GitHub Desktop.
bitrix. prev and next link
<?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,'','&amp;');
$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,'','&amp;');
$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