|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
mcanale Smarty n00b
Joined: 13 Jul 2004 Posts: 2
|
Posted: Tue Jul 13, 2004 6:05 am Post subject: Template Not Parsed When Using "register_resource" |
|
|
I have different templates directories for different modules of this site. I want to include the same header and footer for every module page. Instead of typing {include file="file:/path/to/dir/file.tpl"} I wanted to do just {include file="tpl:file.tpl"} to make life easier but instead of parsing out the file it's just displaying the path. Here is the code i'm using:
[php:1:e54c3128e8]<?php
function tpl_get_template($tpl_name, &$tpl_source, &$smarty_obj) {
$tpl_source = dir_tpl.'default/templates/'.$tpl_name;
return true;
}
?>
[/php:1:e54c3128e8]
So now when I do:
{include file="tpl:file.tpl"}
it returns:
/html/themes/default/templates/file.tpl
instead of the html/design of site.
Thanks for the help! |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue Jul 13, 2004 6:08 am Post subject: |
|
|
Hi.
Smarty delegates the loading of the template to the resource plugin. ie you must retrieve the contents of the template file and pass that back to Smarty. Something like:
[php:1:35dd546f7e]<?php
function tpl_get_template($tpl_name, &$tpl_source, &$smarty_obj) {
$tpl_source = file_get_contents( dir_tpl.'default/templates/'.$tpl_name );
return true;
}
?>[/php:1:35dd546f7e] |
|
Back to top |
|
mcanale Smarty n00b
Joined: 13 Jul 2004 Posts: 2
|
Posted: Tue Jul 13, 2004 2:49 pm Post subject: |
|
|
Thank you, it works perfectly now. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|