When you create a theme, you tell it which theme engine to use when rendering the theme. You do this in the theme's .info file:
name = My Nifty Theme
description = Some description of my nifty theme.
core = 7.x
engine = phptemplate
Although this is great, and allows us to switch which theme engine we want to use for our theme, it presents a problem when we want to use two or more different theme engines. What if, in our theme, we want to use Zengine, and Smarty? This would give us a very slick template engine with the power of Smarty, and the awesome base of Zengine.
How would we accomplish this? Instead of passing in a single "engine" value through the .info file, we would pass in an array:
engines[] = smarty
engines[] = zengine
If we don't specify an engines[] definition, it assume a default of engines[] = phptemplate.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | 304486.patch | 2.31 KB | robloach |
| #11 | 304486.patch | 239 bytes | robloach |
| #8 | themeenginesasmodules.patch | 4.49 KB | robloach |
| #2 | multiplethemeengines.patch | 6.97 KB | robloach |
Comments
Comment #1
dvessel commentedI think this is an interesting idea. The only problems I can foresee is each engine competing for theme functions and templates when they register the same hooks. It could work by processing based on the order it's set .info file.
There's also the extra overhead for templated hooks since there can be more preprocessors and whatever else each engine does.
Comment #2
robloachKicking it off... ETS and Bluemarine ETS are good testing grounds.
Comment #3
cwgordon7 commentedThis is great but in order to be truly awesome color.module needs to be turned into a theme engine.
Comment #4
robloachWhat if we went the other way around and made theme engines modules? phpTemplate would become a module that themes would depend on. Enabling a theme that used both Awesomengine and phpTemplate would enable those modules.
Comment #5
casey commented+1 on theme engines being modules.
Hopefully in D8...
Comment #6
robloach#474684: Allow themes to declare dependencies on modules
Comment #7
robloachDoesn't need to be postponed. This moves themes/engines/phptemplate.engine over to modules/system/phptemplate.engine.... Essentially it moves theme engines over to modules.
Comment #8
robloachComment #9
robloach#8: themeenginesasmodules.patch queued for re-testing.
Comment #11
robloachComment #12
robloachWrong patch... Here's the right one.
Comment #13
fabianx commentedThis won't enable the engine when the module is enabled unfortunately as there is too much other engine specific code going on.
It's really difficult to support two engines within one module how it is structured currently. (and I tried that first as well)
Comment #14
sunSince theme engines are not installed or enabled in any way, #1685492: Convert theme engines into services is the much more appropriate answer.