+7 812 987-54-31
Заказать обратный звонок
Производство сувенирной продукции с логотипом       в Санкт-Петербурге
Режим работы
Понедельник–Пятница: с 10:00 до 18:00
Суббота–Воскресенье: выходные

Оформление заказа на сайте - КРУГЛОСУТОЧНО
Минимальный
заказ 5000 руб.
Перейти в корзину

Пользовательские движки шаблонизации

ГлавнаяКонтентСтатьи
02.10.2009

Пример подключения движка Smarty:

В массиве $arCustomTemplateEngines регистрируется движок Smarty:

global $arCustomTemplateEngines;
$
arCustomTemplateEngines = array(
   "smarty" => array(
      "templateExt" => array("tpl"),
      "function" => "SmartyEngine"
   ),
);

В функции SmartyEngine инициализируются параметры движка в соответствии с требованиями Smarty (см. систему помощи Smarty). Далее в Smarty передаются переменные результатов работы компонента, входных параметров, языковых сообщений и т.д., а в конце вызывается метод обработки и показа шаблона Smarty:

function SmartyEngine($templateFile, $arResult, $arParams, $arLangMessages, $templateFolder, $parentTemplateFolder, $template)
{
   if (!defined("SMARTY_DIR"))
      define("SMARTY_DIR", "<
абсолютныйпутькдвижку Smarty>/libs/");

   require_once( '<
абсолютныйпутькдвижку Smarty>/libs/Smarty.class.php' );

   $smarty = new Smarty;

   $smarty->compile_dir = "<
абсолютныйпутькдвижку Smarty>/templates_c/";
   $smarty->config_dir = "<
абсолютныйпутькдвижку Smarty>/configs/";
   $smarty->template_dir = "<
абсолютныйпутькдвижку Smarty>/templates/";
   $smarty->cache_dir = "<
абсолютныйпутькдвижку Smarty>/cache/";

   $smarty->compile_check = true;
   $smarty->debugging = false;

   $smarty->assign("arResult", $arResult);
   $smarty->assign("arParams", $arParams);
   $smarty->assign("MESS", $arLangMessages);
   $smarty->assign("templateFolder", $templateFolder);
   $smarty->assign("parentTemplateFolder", $parentTemplateFolder);

   $smarty->display( $_SERVER["DOCUMENT_ROOT"].$templateFile );
}

В строке "<абсолютныйпутькдвижку Smarty>" указывается абсолютный путь к движку Smarty.


Страница 2 - 2 из 3
Начало | Пред. | 1 2 3 | След. | Конец


Количество показов: 209

Возврат к списку


Материалы по теме:


[Bitrix\Main\ObjectNotFoundException] 
Forum is not found. (510)
/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/modules/forum/lib/forum.php:305
#0: Bitrix\Forum\Forum->__construct(integer)
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/modules/forum/lib/internals/entityfabric.php:20
#1: Bitrix\Forum\Forum::getById(integer)
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/modules/forum/classes/general/forum_new.php:559
#2: CAllForumNew::GetUserPermission(integer, array)
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/modules/forum/include.php:141
#3: ForumCurrUserPermissions(integer)
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/components/bitrix/forum.topic.reviews/component.php:177
#4: include(string)
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/modules/main/classes/general/component.php:605
#5: CBitrixComponent->__includeComponent()
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/modules/main/classes/general/component.php:680
#6: CBitrixComponent->includeComponent(string, array, object, boolean)
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/modules/main/classes/general/main.php:1039
#7: CAllMain->IncludeComponent(string, string, array, object)
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/components/bitrix/news/templates/.default/detail.php:150
#8: include(string)
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/modules/main/classes/general/component_template.php:789
#9: CBitrixComponentTemplate->__IncludePHPTemplate(array, array, string)
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/modules/main/classes/general/component_template.php:884
#10: CBitrixComponentTemplate->IncludeTemplate(array)
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/modules/main/classes/general/component.php:764
#11: CBitrixComponent->showComponentTemplate()
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/modules/main/classes/general/component.php:712
#12: CBitrixComponent->includeComponentTemplate(string)
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/components/bitrix/news/component.php:216
#13: include(string)
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/modules/main/classes/general/component.php:605
#14: CBitrixComponent->__includeComponent()
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/modules/main/classes/general/component.php:680
#15: CBitrixComponent->includeComponent(string, array, boolean, boolean)
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/modules/main/classes/general/main.php:1039
#16: CAllMain->IncludeComponent(string, string, array, boolean)
	/home/host1328954/k-78.ru/htdocs/suvenir/content/articles/index.php:113
#17: include_once(string)
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/modules/main/include/urlrewrite.php:159
#18: include_once(string)
	/home/host1328954/k-78.ru/htdocs/suvenir/bitrix/urlrewrite.php:2