[英]Change templates/views location in Symfony2
I will be working on project that has different theme for each domain (same application will be serving multiple domains). 我将研究每个域具有不同主题的项目(相同的应用程序将服务于多个域)。
S how to do this stuff with Symfony2 and twig? 用Symfony2和树枝如何做这些东西?
EDIT: I will try to ask this: What or where do I need to rewrite to get custom logic on locating specific templates that symfony uses to render pages. 编辑:我将尝试问这个问题:在查找symfony用于呈现页面的特定模板时,需要重写什么或在何处获取自定义逻辑。
I can't say if first point of your question is a bad practice (and don't know even if it possible, but I would say yes). 我不能说您问题的第一点是否是不好的做法(即使有可能也不知道,但我会说是)。
However, what I would do is some kind of "manager" that will takes responsibility for choosing what kind of template render, based onto your own logic. 但是,我要做的是某种“管理器”,它将负责根据您自己的逻辑选择哪种模板渲染。 Some kind of "intermediate level" between actions and views. 动作和视图之间的某种“中间级别”。
You could create it as a service and use everywhere, without have need to instantiate it every time. 您可以将其创建为服务并在任何地方使用,而无需每次都实例化它。
It could read a file for configuration or, even (but less springy), use a class-internal configuration. 它可以读取文件以进行配置,甚至可以(但不太灵活)使用类内部配置。
Algorithm could be something like this: 算法可能是这样的:
Please, don't ask me some code because it could result in some hundred lines :) 请不要问我一些代码,因为它可能导致几百行:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.