D
D
denism3002019-08-07 22:07:21
1C-Bitrix
denism300, 2019-08-07 22:07:21

How to add page number to description?

The Bitrix forum has a code that is inserted into init.php, how to add a page number to the title in the presence of pagination

AddEventHandler('main', 'OnEpilog', array('CMainHandlers', 'OnEpilogHandler'));
class CMainHandlers
{
    public static function OnEpilogHandler()
    {
        if (isset($_GET['PAGEN_1']) && intval($_GET['PAGEN_1']) > 0) {
            $title = $GLOBALS['APPLICATION']->GetTitle();
            $GLOBALS['APPLICATION']->SetPageProperty('title', $title . ' - cтраница ' . intval($_GET['PAGEN_1']));
        }
    }
}

I tried to supplement it so that the page number is also added to the description:
AddEventHandler('main', 'OnEpilog', array('CMainHandlers', 'OnEpilogHandler'));
class CMainHandlers
{
    public static function OnEpilogHandler()
    {
        if (isset($_GET['PAGEN_1']) && intval($_GET['PAGEN_1']) > 0) {
            $title = $GLOBALS['APPLICATION']->GetTitle();
            $GLOBALS['APPLICATION']->SetPageProperty('title', $title . ' - cтраница ' . intval($_GET['PAGEN_1']));
            $description = $GLOBALS['APPLICATION']->GetDescription();
            $GLOBALS['APPLICATION']->SetPageProperty('description', $description . ' - cтраница ' . intval($_GET['PAGEN_1']));
        }
    }
}

however, does not work. the page number is added to the title, not to the description. How to fix?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sybear, 2019-08-09
@sybear

$description = $APPLICATION->GetProperty("description");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question