Friday , December 20 2024

Title for bitrix pagination

I will not describe why this is necessary, I will only publish a ready-made solution.

else echo $APPLICATION->ShowProperty("meta_title");
if (isset($_GET['PAGEN_1']) && $_GET['PAGEN_1']!=1) { echo " Page ".$_GET['PAGEN_1']; }
if (isset($_GET['PAGEN_2']) && $_GET['PAGEN_2']!=1) { echo " Page ".$_GET['PAGEN_2']; }
if (isset($_GET['PAGEN_3']) && $_GET['PAGEN_3']!=1) { echo " Page ".$_GET['PAGEN_3']; }

The disadvantage of this condition is that the listing is manual, and if you have 100 pages of pagination, this copy-paste will not be very comfortable. But in Bitrix there is no comfort at all.

A detailed version from some project with which I worked for the SEO customization:

if(preg_match ('/catalog\/(.*)\/\?PAGEN_1=2+/i', $_SERVER['REQUEST_URI'])) {
echo $APPLICATION->ShowTitle(); echo ' - page № 2';
}
else if(preg_match ('/catalog\/(.*)\/\?PAGEN_1=3+/i', $_SERVER['REQUEST_URI'])) {
echo $APPLICATION->ShowTitle(); echo ' - page № 3';
}
else if(preg_match ('/catalog\/(.*)\/\?PAGEN_1=4+/i', $_SERVER['REQUEST_URI'])) {
echo $APPLICATION->ShowTitle(); echo ' - page № 4';
}
else if(preg_match ('/catalog\/(.*)\/\?PAGEN_1=5+/i', $_SERVER['REQUEST_URI'])) {
echo $APPLICATION->ShowTitle(); echo ' - page № 5';
}
else if(preg_match ('/catalog\/(.*)\/\?PAGEN_1=6+/i', $_SERVER['REQUEST_URI'])) {
echo $APPLICATION->ShowTitle(); echo ' - page № 6';
}
else if(preg_match ('/catalog\/(.*)\/\?PAGEN_1=7+/i', $_SERVER['REQUEST_URI'])) {
echo $APPLICATION->ShowTitle(); echo ' - page № 7';
}
else if(preg_match ('/catalog\/(.*)\/\?PAGEN_1=8+/i', $_SERVER['REQUEST_URI'])) {
echo $APPLICATION->ShowTitle(); echo ' - page № 8';
}
else if(preg_match ('/catalog\/(.*)\/\?PAGEN_1=9+/i', $_SERVER['REQUEST_URI'])) {
echo $APPLICATION->ShowTitle(); echo ' - page № 9';
}
else if(preg_match ('/catalog\/(.*)\/\?PAGEN_1=10+/i', $_SERVER['REQUEST_URI'])) {
echo $APPLICATION->ShowTitle(); echo ' - page № 10';
}

else $APPLICATION->ShowTitle();

The same manual copy-paste is used here, but it is more clearly described.

Here is a way to automatically display the page number in the title:

$APPLICATION->ShowTitle(true); echo (preg_match('{.*?\?PAGEN_\d=(\d+)}', $_SERVER['REQUEST_URI'], $m) ? " – page ".$m[1] : '');

I draw your attention – this code needs to be tested, I do not remember where I used it.

Here is the detailed and quite beautiful code, with an additional condition for the news title:

<?

$t_add = (preg_match('{.*?\?PAGEN_\d=(\d+)}', $_SERVER['REQUEST_URI'], $m) ? " – page ".$m[1] : '');
$m_title = $APPLICATION->GetPageProperty('title');
if(!empty($m_title)){
	echo '<title>'.$m_title.$t_add.'</title>';
}else{
?>
	<title><?$APPLICATION->ShowTitle(); echo $t_add; ?> <?if (preg_match('#/news/\w#siU', $_SERVER['REQUEST_URI'])) echo " | News articles ";?> </title>
<?}?>

About admin

Hi there! My name is Iryna, I am a web developer from Ukraine. While working on freelance projects I often face different technical issues and in this blog I publish articles on how to solve them. I am also interested in digital drawing and in this blog you will find brief tutorials that helped me and hopefully can help you as well.

Check Also

301 redirect in .htaccess from uppercase to lowercase characters

In web development, managing URL consistency is crucial for SEO and user experience. One common …

Leave a Reply

Your email address will not be published. Required fields are marked *