D
D
Dmitry Grabko2017-05-02 17:14:38
1C-Bitrix
Dmitry Grabko, 2017-05-02 17:14:38

How to add page number to pagination page meta tag?

The site implemented pagination in the catalog. The title is rendered through a standard component.
The template displays as follows: How to add a condition under which a page like www.site.ru/catalog/?PAGEN_1=2 will have "Page 2" in the Title?
<title><?$APPLICATION->ShowTitle()?></title>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav, 2017-05-02
@Dima_So

I haven't written in php for a long time, but it seems like this

<title><?
$APPLICATION->ShowTitle();
if (isset($_GET["PAGEN_1"]) and is_int($_GET["PAGEN_1"])) 
{
    echo "Страница ".$_GET["PAGEN_1"];
}
?></title>

A
Alexey Burlaka, 2017-05-03
@AlexeyGfi

How I would do it:
The text “ Page ” should be correctly moved to /lang/ files and then the call to the previous line will be like this:

$APPLICATION->SetPageProperty( 
    'pagination_suffix', 
    \Bitrix\Main\Localization\Loc::getMessage( 'PAGE_IN_BROWSER_TITLE' ) . 'zZz' 
  );

Template:
- knows what page number;
- saves us from hemorrhoids with tracking PAGEN_1, PAGEN_2, PAGEN_3 , ... We
take the page number from 3. The output of the title would be supplemented like this:
(!) There is a risk that this component template is cached and therefore the first call will give us pagination, and then SetPageProperty will stop working. I move the code from template.php to component_epilog.php (I almost always do this already) and so all calls are not cached.
To forward arResultin component_epilog.php, you need to write in result_modifier.php :
That is, we have in the folder with the component template:
• result_modifier.php (create if it does not exist) with variable forwarding;
• template.php, in which only the voting for the composite remains ; • component_epilog.php, where the actual output to the screen and execution of the headings are written. $this->setFrameMode(true);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question