Skip to content

Instantly share code, notes, and snippets.

@konratnox
Created February 12, 2019 12:41
Show Gist options
  • Save konratnox/583b505d2abbab21f268efb3e9b8249b to your computer and use it in GitHub Desktop.
Save konratnox/583b505d2abbab21f268efb3e9b8249b to your computer and use it in GitHub Desktop.
<?
if ($arResult['ARR_NAV']["NavPageNomer"] == 2) {
// $APPLICATION->SetPageProperty("robots", "noindex, follow");
Bitrix\Main\Page\Asset::getInstance()->addString("<link rel='prev' href='https://{$_SERVER['SERVER_NAME']}{$arResult['LIST_PAGE_URL']}'>");
}
elseif ($arResult['ARR_NAV']["NavPageNomer"] > 2) {
// $APPLICATION->SetPageProperty("robots", "noindex, follow");
$prevPage = $arResult['ARR_NAV']["NavPageNomer"] - 1;
Bitrix\Main\Page\Asset::getInstance()->addString("<link rel='prev' href='https://{$_SERVER['SERVER_NAME']}{$arResult['LIST_PAGE_URL']}?PAGEN_{$arResult['ARR_NAV']["NavNum"]}={$prevPage}'>");
}
if ($arResult['ARR_NAV']["NavPageNomer"] < $arResult['ARR_NAV']["NavPageCount"]) {
$nexPage = $arResult['ARR_NAV']["NavPageNomer"] + 1;
Bitrix\Main\Page\Asset::getInstance()->addString("<link rel='next' href='https://{$_SERVER['SERVER_NAME']}{$arResult['LIST_PAGE_URL']}?PAGEN_{$arResult['ARR_NAV']["NavNum"]}={$nexPage}'>");
}
Bitrix\Main\Page\Asset::getInstance()->addString("<link rel='canonical' href='https://{$_SERVER['SERVER_NAME']}{$arResult['LIST_PAGE_URL']}'/>");
<?
$arNavResult = array();
$arNavResult['NavNum'] = $arResult['NAV_RESULT']->NavNum;
$arNavResult['NavPageNomer'] = $arResult['NAV_RESULT']->NavPageNomer;
$arNavResult['NavPageCount'] = $arResult['NAV_RESULT']->NavPageCount;
$arResult['ARR_NAV'] = $arNavResult;
$this->__component->SetResultCacheKeys(array('ARR_NAV'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment