|
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 |
schildi Smarty Regular
Joined: 11 Mar 2005 Posts: 81
|
Posted: Tue Nov 06, 2007 9:39 am Post subject: problems with is_cached function |
|
|
hi,
i dont know why i do not get a 'true' from the smarty->is_cached function:
//smarty->caching is set to 1
$smarty->caching = 1;
if($smarty->is_cached("pg.tpl_index.tpl", "9a07502522ddaf254885c72af8cbd645")) echo("site cached!");
else echo("site not cached!");
//result is "site not cached!"
cache content is:
9a07502522ddaf254885c72af8cbd645^%%82^826^82667930%%pg.tpl_index.tpl
why isnt the result true? dont know what do do.. - can anyone help? |
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Tue Nov 06, 2007 10:28 am Post subject: |
|
|
I'm pretty sure, you never call Code: | $smarty->display('pg.tp_index.tpl', "9a07502522ddaf254885c72af8cbd645"); |
Therefore Smarty is right and this site with this cache_id isn't cached.
Take a closer look at
http://smarty.php.net/manual/en/api.is.cached.php
to see how is_cached really works. _________________ Darn computers always do what I tell them to instead of what I want them to do. |
|
Back to top |
|
schildi Smarty Regular
Joined: 11 Mar 2005 Posts: 81
|
Posted: Tue Nov 06, 2007 10:40 am Post subject: |
|
|
i do call
$smarty->fetch($smarty->template_dir."pg.tpl_index.tpl", "065e13a4ad77e322079da9bcc8f26dfa");
and i thought i dont need to declare $smarty->template_dir when using is_cached function
thanks!! |
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Tue Nov 06, 2007 2:19 pm Post subject: |
|
|
IMO this should be sufficient
$smarty->fetch('pg.tpl_index.tpl', $cache_id);
Smarty looks for the template in $smarty->template_dir anyway. _________________ Darn computers always do what I tell them to instead of what I want them to do. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue Nov 06, 2007 7:09 pm Post subject: |
|
|
AFAIK, the cacher (actually, the filename hasher, I suppose) will treat "pg.tpl_index.tpl" differently than "/some/path/pg.tpl_index.tpl". Thus, Celeb's comments do apply here. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Nov 06, 2007 7:53 pm Post subject: |
|
|
Also you must use the same cache_id for the fetch and is_cached call. In your example you have used different strings. |
|
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
|