Re: Variable template directories.

From: Date: Thu, 07 Mar 2002 10:13:57 +0000
Subject: Re: Variable template directories.
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2964@lists.php.net to get a copy of this message
Hi Right, I have run into the same problem and mentioned this at least 2 times on this list. I have suggested to have a rewriter function for each resource identifier before it is processed further. The idea is that you can specify in your templates: {include file="template.tpl"} and that that function rewrites it to something else, depending on the magic you want to apply. In your example adding the directory for the current theme. Your rewrite function would do something like this: function rewrite_resource($resource) { global $theme_dir; return $theme_dir . "/" . $resource; } I have implemented this by altering the Smarty.class.php file to have $_smarty_tpl_file = $this->rewrite_resource($_smarty_tpl_file); as the first line of code after the 'global' definition of the method fetch() and for the include directives I have as the first line of _smarty_include(): $_smarty_include_tpl_file = $this->rewrite_resource($_smarty_include_tpl_file); Then I introduce the method rewrite_resource($resource) as an initially indentity function, just returning the resource unmodified. You can then override that in a subclass. The modifications are against smarty 1.5.1, but they'll probably work on 2.0 versions as well. Monte: couldn't this be added to smarty? It doesn't seem expensive, and people who don't need it, don't have to override rewrite_resource. Greetz, Ralphm

« previous php.smarty.general (#2964) next »