multiple template directories
- tomcat4x
- Member | 22
Hi,
first of all congratulations to this framework.
But i am not sure, if this framework fulfill my requirements.
.
I am looking for a solution to have multiple template sets. All the templates
should be stored in one directory with subdirectorties which are named
different.
/wwwroot
/templates
/templateset1
/templateset2
Dependend on a parameter (from neon or later from database) nette should chose the corresponding templateset
Is this possible with nette? If yes, whats the best way?
- Šaman
- Member | 2667
Templates are finded by formatTemplateFiles()
and formatLayoutTemplateFiles() methods in Presenter
.
Overwrite that methods in your BasePresenter and change directory as
you can.
Last edited by Šaman (2015-07-02 11:51)
- tomcat4x
- Member | 22
Here is my solution:
I overwrite the two functions formatTemplateFiles() and formatLayoutTemplateFiles() and added a private function setTemplateName() which is called at the beginning of the two overwritten functions.
The function setTemplateName() is getting the default database connection from the context, makes a query on the table “templates” and overwrites the private property $templateName.
The two functions formatTemplateFiles() and formatLayoutTemplateFiles() are now looking for a directory under the base www directory where the index.php is located ($_SERVER[‘SCRIPT_FILENAME’]) for a directory /templates/templateName.
I know, that there are some things to improve but it works.
Last edited by tomcat4x (2015-07-02 14:36)
- alnux
- Member | 139
hi there, on this proyect the system select template automatically by country (github file)