Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Template Not Parsed When Using "register_resource"

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
mcanale
Smarty n00b


Joined: 13 Jul 2004
Posts: 2

PostPosted: Tue Jul 13, 2004 6:05 am    Post subject: Template Not Parsed When Using "register_resource" Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue Jul 13, 2004 6:08 am    Post subject: Reply with quote

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
View user's profile Send private message
mcanale
Smarty n00b


Joined: 13 Jul 2004
Posts: 2

PostPosted: Tue Jul 13, 2004 2:49 pm    Post subject: Reply with quote

Thank you, it works perfectly now.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP