S
S
strangerfrompast2021-12-01 05:33:31
PHP
strangerfrompast, 2021-12-01 05:33:31

How to add areas to the site on bitrix depending on the subdomain?

There is a site already quite old, on wordpress
. There we have implemented the implementation of dynamic subdomains, and there are areas in the templates that change depending on the current subdomain.

Example:

code inserted in footer template

<?php
  // different footer data depends on subdomain
  get_template_part('templates/phone');
?>

and in the templates folder there is a phone.php file
<?php
  $domain = explode('.', $_SERVER['SERVER_NAME']);
  if (sizeOf($domain) == 3) {
    $file = realpath(__DIR__ . '/../' . ($part = 'templates/' . $domain[0] . '/phone') . '.php');
    if (file_exists($file)) {
      get_template_part($part);
      return;
    }
  }
  /**
   * EDIT PHONE DATA BELOW
   */
?>
<p>+7 999 999 99 99</p>


But we are now moving to bitrix, and I would like to know if it will be possible to implement the change of template pieces on dynamic subdomains using the same solution?
And if it doesn’t work, is there a similar simple way to solve the problem in Bitrix?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
no_one_safe, 2021-12-01
@strangerfrompast

It will turn out. And there are more elegant and convenient ways to implement it.
For example, phones should not be stored in a git, but in a database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question