RE: [SMARTY] fetch() problem
| From: | luis | Date: | Tue, 06 May 2003 18:38:36 +0000 |
| Subject: | RE: [SMARTY] fetch() problem | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-9486@lists.php.net to get a copy of this message | ||
If the directory is under your templates dir you can use
$smarty->fetch("$theme/foo.tpl");
If not you have a problem :-)
One my applications uses themes, what I did was to make themes sibdirs
of templates, and then I overloaded the fetch method to search in
templates/$theme/XXX.tpl first and if the template is not there then
revert to templates/XXX.tpl, in this way a theme can potentially
redefine zero, one or all the templates as needed.
Something like this.....
function fetch($_smarty_tpl_file, $_smarty_cache_id = null,
$_smarty_compile_id = null, $_smarty_display = false) {
global $style;
global $style_base;
if(isset($style)&&isset($style_base)) {
if(file_exists("templates/styles/$style_base/$_smarty_tpl_file"))
{
$_smarty_tpl_file="styles/$style_base/$_smarty_tpl_file";
}
}
$_smarty_cache_id = $language.$_smarty_cache_id;
$_smarty_compile_id = $language.$_smarty_compile_id;
return parent::fetch($_smarty_tpl_file, $_smarty_cache_id,
$_smarty_compile_id, $_smarty_display);
}
Luis.
> -----Original Message-----
> From: Jean-Marc Fontaine [mailto:webmaster@dyingculture.net]
> Sent: Tuesday, May 06, 2003 3:29 PM
> To: smarty-general@lists.php.net
> Subject: [SMARTY] fetch() problem
>
>
> Hi all,
>
> I am trying to fetch a template that is not in my template
> directory but I can not make it work. To be more precise I
> use themes on my site so my template directory changes
> depending on the theme used but I also use a unique template
> for displaying some debug informations which is in a separate
> directory.
>
> I tried by passing the absolute and the relative paths to the
> template file.
>
> Is there a way to do that ?
> Thanks a lot.
>
> Jean-Marc
>
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>