P
P
Pavel Sidorov2020-03-05 10:01:55
1C-Bitrix
Pavel Sidorov, 2020-03-05 10:01:55

How to correctly determine the site id when sending a CEvent::Send message?

Kind.

Multisite is done on folders. Everything is specified in the settings of the second site. The mail template is attached to the second site. The code below is a handler and is located in a separate folder in the template of the second site. When submitting the form, the site id is incorrectly determined. In public, I checked what is displayed by the SITE_ID constant - everything is OK "s2". If you attach the mail template to s1, then everything works. How to specify id correctly? why Error?

<?
define("NO_KEEP_STATISTIC", true);
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");


if (isset($_POST) && count($_POST) > 0) {
    switch($_POST['a']) {
        
    case 'callback':
      $mess = '';
            if (strlen(trim($_POST['name'])) == 0) {
                $mess .= '<p><font class="errortext">Укажите ваше имя.</font></p>';
            }
            if (strlen(trim($_POST['phone'])) < 10) {
                $mess .= '<p><font class="errortext">Укажите номер телефона в федеральном формате.</font></p>';
            }
            if ($mess == '') {

                CEvent::Send("CALLBACK", SITE_ID, array(
                    "SERVICE" => trim($_POST['service']),
                    "NAME" => trim($_POST['name']),
                    "PHONE" => trim($_POST['phone'])
                ), "N");
        $mess = '<div class="mf-ok-text"><b>Спасибо, ваше сообщение принято.</b></div>';
            }
      echo $mess;//.'|'.$code;
            break;
    }
}

require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2020-03-05
@pavel__sidorov

and if so \Bitrix\Main\Application::getInstance()->getContext()->getSite() ??

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question