roadster31 / template-switcher-module
0.5.1
2023-07-04 13:33 UTC
Requires
- thelia/installer: ~1.1
This package is auto-updated.
Last update: 2024-09-04 15:58:00 UTC
README
此模块允许在运行时切换前端模板,使用URL /ts/<nom-du-template-front>
,例如 http://domain.tld/ts/my_super_template
<nom-du-template-front>
必须是 templates/frontOffice
的子目录名称。
就是这样。
从技术角度来看,该模块定义了一个模板助手,它会查找会话中的活动模板而不是数据库中的模板。
该模块提供了一个名为 TemplateSwitcherEvent 的事件,可以通过 TemplateSwitcherEvent::SWITCH_TEMPLATE_EVENT 来分发。它允许更改任何模板,而不仅仅是前端模板。例如
$event = new TemplateSwitcherEvent('nom-du-template')
$event->setTemplateType(TemplateDefinition::BACK_OFFICE)
$this->getDispatcher()->dispatch(
TemplateSwitcherEvent::SWITCH_TEMPLATE_EVENT,
new TemplateSwitcherEvent('nom-du-template')
);