|
Zyx
|
 |
« Reply #1 on: April 26, 2009, 06:21:23 » |
|
Hi, currently there are two ways:
1. In sourceDir you can define more than one path as an assotiative array. You could register there paths for your modules under their unique name (i.e. "news" or "articles") and then choose the template names with this module prefix: news:template1.tpl etc. templates_c remains the same for all the modules and OPT pays attention not to overwrite any compiled template by accident. You could also try to use stdStream configuration option to select the default template path, but in currently released versions, this would require a bit help on the template side. In the near future, there should appear a kind of simplification that I've invented.
2. I had a quite similar problem some time ago, but with OPT 1.x. I simply extended Opt_Class and wrote a new method to locate templates on the filesystem. It gives better results, but it is harder to achieve, as you have to hack some internal OPT systems.
There are four methods that are used to create and check the paths:
- Opt_Class::_stream() - produces a path to the original template. - Opt_View::_convert() - produces a path to the compiled template. - Opt_View::_preprocess() - checks if the template exists on the filesystem and needs to be recompiled (it uses _stream() and _convert()). - Opt_View::_massPreprocess() - like above, but this is the version for the template inheritance that checks a list of templates at once to reduce the number of disk operations.
In the basic version, just _stream() and _convert() need to be changed to look for the template in more than one directory automatically, and to provide a unique file name within templates_c/ directory. You have to remember that in CM_PERFORMANCE mode OPT uses only the _convert() method, if you are going to use it, you have provide a support for this case.
The more extended version affects also the last two methods in order not to perform unnecessary disk operations.
In general, I see I must provide some dedicated solution for this problem, because you are not the first person asking for it :).
|