php Canonical,rel next,prevвnews.list

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Canonical,rel next,prevвnews.list相关的知识,希望对你有一定的参考价值。

<?
$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'));
<?

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']}'/>");

以上是关于php Canonical,rel next,prevвnews.list的主要内容,如果未能解决你的问题,请参考以下文章

php rel next prev bx paging_params

使用左右箭头导航到 rel=next 和 rel=prev 页面

Symfony2.3分页如何实现rel=prev和rel=next?

Google rel="next/prev" 用于动态分页?

link标签rel="alternate"属性的作用及用法

在灯上使用 mod_rewrite 制作 seo/canonical url