Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

register_resource function all wacked up...

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
seņor64
Smarty n00b


Joined: 16 Jun 2003
Posts: 3
Location: boston

PostPosted: Mon Jun 16, 2003 9:14 pm    Post subject: register_resource function all wacked up... Reply with quote

hi folks new to the forum here but have been using Smarty for about 2 years now, loving it, could not live without it. Really.

that said - I upgraded one of my sites today to 2.5.0 and the register_resource function I use seems to be broken now. Everytime I have ever upgraded Smarty this seems to come up. I hope someone can tell me what the deal is here:

I have a file "resource.buffered_template.php" in the plugins/ dir. I won't bore you with its exact contents. But in the file I had
Code:
$this->register_resource("buffered_template", array("smarty_resource_buffered_template_source",
                                       "smarty_resource_buffered_template_timestamp",
                                       "smarty_resource_buffered_template_secure",
                                       "smarty_resource_buffered_template_trusted"));


and the functions in that file are named as described in the docs. This was all working A-OK before the upgrade.

Now I get
Code:

Smarty error: unable to read template resource: "buffered_template:admin_homenav"
at line 1042 of /home/sz/public_html/vera/phlyness/Smarty/Smarty.class.php


on pages that use the resouce via
Code:

$smarty->display("buffered_template:admin_homenav");


Any ideas? debugging does not seem to give me anything helpful. The resource file does not seem to be getting included now either. But when I require() it manually I get the same result. I need a couple bologna sandwiches and some sleep. Hope you can help in the meantime
thanks
_________________
don't sweat the petty things, and don't pet the sweaty things -- George Carlin
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Mon Jun 16, 2003 10:34 pm    Post subject: Reply with quote

hello,

i don't know the exact reason for your problems, but it seems you are mixing two approaches here:

you can register resources in two ways:

#1 explicitely: define the functions (maybe via a require) and call register_resource() accordingly.

#2 implicetely via an autoloaded plugin: the file *has* to be named 'resource.[name].php' and the functions inside it *have* to follow a special naming scheme.


it seems you choosed #2 so there is no need to call register_resource() explicitely. smarty registers it for you if it finds and loads the plugin.

HTH (i know the docs may be a bit sparse and/or misleading regarding resources)
messju
Back to top
View user's profile Send private message Send e-mail Visit poster's website
boots
Administrator


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

PostPosted: Tue Jun 17, 2003 12:01 am    Post subject: Reply with quote

NOTE: if you choose #2, then your resource must live in a plugin directory known to Smarty. Also, you should use a full path when defining your Smarty directories--at least, this is true for 2.5.0.
Back to top
View user's profile Send private message
seņor64
Smarty n00b


Joined: 16 Jun 2003
Posts: 3
Location: boston

PostPosted: Tue Jun 17, 2003 1:46 pm    Post subject: solved! w00t! Reply with quote

thanks guys. You got me going in the right direction, I dug into the Smarty.class.php - it turns out my *_timestamp() function for the resource looked like this:
Code:

function smarty_resource_buffered_template_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj) {
        if ($tpl_timestamp = filemtime($_SERVER["PATH_TRANSLATED"])) {
            return true;
        }
        else {
            return false;
        }
    }


but since I had also upgraded to Apache 2.0.x, the var PATH_TRANSLATED was no longer available. I put in an elseif() looking for SCRIPT_FILENAME and now the timestamp of the originating script is found properly. All is well Very Happy

I'd also like to say that the Smarty code is remarkably clear and easy to get into. good stuff.
_________________
don't sweat the petty things, and don't pet the sweaty things -- George Carlin
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General 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