| Benjamin Sims 2004-07-08, 4:04 pm |
| > Sorry about the title, but my problem is a little hard to put succintly.
>
> I have an application which uses a base set of templates, with additional
> template directories allowing for different 'views'.
>
> For example
>
> /Smarty/templates/mainDir - contains all the templates
> /Smarty/templates/alternative1 - contains only templates for which an
> alternative version is required
> /Smarty/templates/alternative2 - ditto
>
> This all works fine, with the template_dir setting of Smarty being an
> array.
>
> The problem comes with loading config files. I have handled this by using
> a template called 'loadConfig.tpl', which only in the mainDir contains
>
> {config_load file ="configfile.conf" scope="global"}
>
> This can be overidden by placing a loadConfig.tpl in one of the
> alternative directories, containing for example:
>
> {config_load file ="configfile.conf" scope="global"
> section="alternative1"}
>
> The config file itself contains:
>
> -----------------------------------------------
> #global variables - can be overridden by sections if necessary
>
> banner = "main_banner.jpg"
> mainTitle = "Welcome to MainApp"
>
>
> [alternative1]
>
> banner ="alternative_banner.jpg"
> mainTitle = "Welcome to Alternative"
> ------------------------------------------------
>
> The problem comes with the compilation of templates - once a template is
> compiled for alternative1 that banner and title displays even if a user
> accesses the main application.
>
> So, the question is: should I change the architecture, or is there an easy
> way I can tell smarty to compile different sets of templates according to
> the config file section/ directory? At the moment I have set
> force_compile->true, but I know this is a bad idea.
>
> Thanks for any ideas,
> Benjamin Sims
>
>
|