|
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 |
shuther Smarty Rookie
Joined: 04 Jan 2004 Posts: 13
|
Posted: Tue Jan 13, 2004 3:12 pm Post subject: auto cache_id |
|
|
I am not sure that it is doesn't exist, but it should interest a lot of people.
Here is the thing : each .php file has just:
Code: | $smarty->display('index.tpl')
|
And the index.tpl contains the required includes of the main body (.tpl) and some (.php) files.
Now, when I use the $smarty->display, I don't know which cache_id I should use. but when the display is finshed (the called function), I know them.
I think we could add a function (a plugin or something else) that we could call in a .tpl file like this:
Code: | {addCacheId('username', $userid)}
{addCacheId('skin', 'skin01')}
|
and to get a cache_id=serialize(the_array_above) automatically (the smarty jobs)?
Do you think it is something we could do? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Jan 13, 2004 3:33 pm Post subject: Re: auto cache_id |
|
|
shuther wrote: | Do you think it is something we could do? |
i don't think we could. we would have to travel back in time and call display() again with the obtained cache_id from the future. |
|
Back to top |
|
shuther Smarty Rookie
Joined: 04 Jan 2004 Posts: 13
|
Posted: Thu Jan 15, 2004 2:52 pm Post subject: How to implement it. |
|
|
Here is the thing.
The first time, we generate an array of variables that makes the page different, such as:
array('username' => 'user1',
'SID' => '3243423435353446765', ...)
Then, we serialize it somewhere
When we want to load the cache again, we take the array of the elements required:
array('username' ,
'SID' , ...)
And for each element, we call a function registered (for each element of the array) in smarty, for example:
Code: |
$val = $this->LoadCacheParameters($key);
|
Where $key would be 'username', ....; and $val will be put in the array;
then, we can figure out if the page has been cached or not (if the array is a cache_id).
I am not sure I am clear, but what do you think about the algorithm.
?>[/php] |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Jan 15, 2004 3:26 pm Post subject: |
|
|
The cache_id must be known before display() is called. This shouldn't be difficult to do, write a PHP function that figures it out the way you want. |
|
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
|