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

I can't find the function setCaching() anywhere in my Smarty

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
pedrotester
Smarty Rookie


Joined: 06 Jun 2019
Posts: 33

PostPosted: Fri Aug 16, 2019 9:33 pm    Post subject: I can't find the function setCaching() anywhere in my Smarty Reply with quote

Hello,

I have enabled caching with setCaching and it works fine but when I check in my files, I can't find anything related to that method/function (with grep). I'm a beginner in PHP so I really don't understand why/how.

Maybe the function name is dynamically formed?

Can someone enlighten me?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1613

PostPosted: Wed Aug 21, 2019 8:21 am    Post subject: Reply with quote

What name/function you are referring to?
Back to top
View user's profile Send private message
pedrotester
Smarty Rookie


Joined: 06 Jun 2019
Posts: 33

PostPosted: Wed Aug 21, 2019 5:52 pm    Post subject: Reply with quote

Quote:
$smarty->setCaching(Smarty::CACHING_LIFETIME_CURRENT);


As written here: https://www.smarty.net/docs/en/caching.tpl


I can find "caching" but not "setCaching" however both enable caching, so i'm just confused
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1613

PostPosted: Thu Aug 22, 2019 4:58 am    Post subject: Reply with quote

Use setCaching()

And yes, these are dynamically inserted.
Back to top
View user's profile Send private message
pedrotester
Smarty Rookie


Joined: 06 Jun 2019
Posts: 33

PostPosted: Sat Sep 21, 2019 9:01 pm    Post subject: Reply with quote

(i had no internet for a while and forgot this)

So you mean that "setCaching" is not present in the files, because the word "setCaching" is dynamically created?

Because I don't find the word "setCaching" at all in my files, yet it works. (Sorry to repeat but I want to be sure)
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 263
Location: West Coast

PostPosted: Sat Sep 21, 2019 11:07 pm    Post subject: Reply with quote

In Smarty 3.1.33, in the file /sysplugins/smarty_internal_templatebase.php, at line 358, I found setCaching($caching).
Back to top
View user's profile Send private message
pedrotester
Smarty Rookie


Joined: 06 Jun 2019
Posts: 33

PostPosted: Mon Nov 04, 2019 5:46 pm    Post subject: Reply with quote

bsmither wrote:
In Smarty 3.1.33, in the file /sysplugins/smarty_internal_templatebase.php, at line 358, I found setCaching($caching).


In "Smarty.class.php" I have this:
Code:
    const SMARTY_VERSION = 'Smarty-3.1.8';


Now in "sysplugins/smarty_internal_templatebase.php", I don't have any "setCaching", but at line 352-360, this:

Code:

        } else {
            if ($merge_tpl_vars) {
                // restore local variables
                $_template->tpl_vars = $save_tpl_vars;
                $_template->config_vars =  $save_config_vars;
            }
            // return fetched content
            return $_output;
        }


Weird, no??? Or it has been added a few minor versions later?

Note: i wouldn't know how to update Smarty without breaking stuff (or how to check what has been broken)
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Nov 06, 2019 10:11 pm    Post subject: Reply with quote

All Smarty properties can be accessed by corresponding getter/setter functions. However depending of the release not all of these functions had been implemented in real code but the generic __call interface
Back to top
View user's profile Send private message
pedrotester
Smarty Rookie


Joined: 06 Jun 2019
Posts: 33

PostPosted: Fri Nov 29, 2019 11:32 pm    Post subject: Reply with quote

alright still no idea how it can work while not being in the code
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1613

PostPosted: Sun Dec 01, 2019 10:17 pm    Post subject: Reply with quote

pedrotester wrote:
alright still no idea how it can work while not being in the code


Through MAGIC!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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