V
V
Vladimir2018-03-12 21:47:45
1C-Bitrix
Vladimir, 2018-03-12 21:47:45

How to change meta tags when multisite?

Hello. Does anyone know how to correctly implement the following functionality.
I have a domain and 2 subdomains.
Domain: test.ru
Subdomains: phone.test.ru and phone2.test.ru
Subdomains are made just like aliases.
I need to be able to change Meta tags when editing a regular text page from the public part.

<?
if($_SERVER["HTTP_HOST"] == "phone.test.ru"){
  $APPLICATION->SetPageProperty("description", "Контакты Один");;
  $APPLICATION->SetTitle("Контакты Один");
}elseif($_SERVER["HTTP_HOST"] == "phone2.test.ru"){
  $APPLICATION->SetPageProperty("description", "Контакты 2");
  $APPLICATION->SetTitle("Контакты 2");
}else{
  $APPLICATION->SetPageProperty("description", "Другие контакты");
  $APPLICATION->SetTitle("Другие контакты");
};
?>

This code is working - but it breaks when editing from the public part of the site. And, in general, it is a crutch. I think there is another way.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Epifanov, 2018-03-13
@kacheleff

you can make a wrapper component that will have to be placed on all pages.
the component parameters will be the values ​​of the meta tags to be set.
in this case, all the logic for setting meta tags will be encapsulated in the component.
it is also possible to break such code if you remove the component - but this can only be avoided by prohibiting editing files from the public part at all

A
Alexander, 2018-03-15
@idruweb

Get properties - meta tags for the same subdomain
and edit them

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question