-
-
Save Elvinz/8b546d121c7ed96ec74fdd5f1db05c1c to your computer and use it in GitHub Desktop.
bitrix Передать переменные в шаблон Битрикс
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Глобальная переменная | |
Чтобы сделать переменную доступную из любого места кода, можно использовать файл bitrix/.settings.php. | |
return array ( | |
// … | |
'contacts' => array( | |
'value' => array( | |
'phone' => '111111111', | |
'email' => '[email protected]', | |
), | |
), | |
// … | |
) | |
$contacts = \Bitrix\Main\Config\Configuration::getValue("contacts"); | |
$contacts['phone']; // 111111111 | |
$contacts['email']; // [email protected] | |
/************************/ | |
Переменные для указанного раздела | |
Создать переменные, которые будут доступны в указанном разделе, можно через razdel_name/.section.php. | |
$arDirProperties = array( | |
'engine' => 'Битрикс', | |
); | |
$APPLICATION->GetDirProperty('engine'); // Битрикс | |
/**********************/ | |
Передать переменные в шаблон только для текущей страницы | |
В начале любой страницы с контентом можно вставить метод $APPLICATION->SetPageProperty(). | |
$APPLICATION->SetPageProperty('city', 'Москва'); | |
$APPLICATION->GetPageProperty('city'); // Москва |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment