Re: Variable template directories.

From: Date: Thu, 07 Mar 2002 14:22:35 +0000
Subject: Re: Variable template directories.
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2968@lists.php.net to get a copy of this message
I don't see a reason to do this, you can accomplish the same thing (or basically anything you want) with a custom resource function. {include file="theme:$theme_dir:$template"} Monte Ralph Meijer wrote: > > 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 > > --- > You are currently subscribed to smarty as: monte@ispi.net > To unsubscribe send a blank email to $subst('Email.Unsub') > Visit Smarty's homepage at > http://www.phpinsider.com/php/code/Smarty/ -- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc.

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