Skip to content

Instantly share code, notes, and snippets.

@morozVA
Created January 3, 2018 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save morozVA/850ca31e885ec4e10010965c3b6dede5 to your computer and use it in GitHub Desktop.
Save morozVA/850ca31e885ec4e10010965c3b6dede5 to your computer and use it in GitHub Desktop.
bitrix Передать переменные в шаблон Битрикс
Глобальная переменная
Чтобы сделать переменную доступную из любого места кода, можно использовать файл bitrix/.settings.php.
return array (
// …
'contacts' => array(
'value' => array(
'phone' => '111111111',
'email' => 'example@know-online.com',
),
),
// …
)
$contacts = \Bitrix\Main\Config\Configuration::getValue("contacts");
$contacts['phone']; // 111111111
$contacts['email']; // example@know-online.com
/************************/
Переменные для указанного раздела
Создать переменные, которые будут доступны в указанном разделе, можно через 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