1
votes

I will be working on project that has different theme for each domain (same application will be serving multiple domains).

  1. I need to change location of templates completely outside the application folder, possible on another volume
  2. I need to make it work with multiple domains with multiple themes - i guess theres cache problem

S how to do this stuff with Symfony2 and twig?

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.

1
Is it correct all I need to do is rewrite TemplateReference? But I dont understans how they did it here then: github.com/liip/LiipThemeBundleZdeněk Topič

1 Answers

0
votes

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:

  • Take into account your request
  • "Eat" data and "spit out" the correct template (name)
  • Pass template (name) to your view
  • Extend (dinamically) the template given by your manager

Please, don't ask me some code because it could result in some hundred lines :)