Created
January 3, 2018 14:52
-
-
Save morozVA/850ca31e885ec4e10010965c3b6dede5 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