|
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 |
BKcore Smarty n00b
Joined: 17 Sep 2011 Posts: 3
|
Posted: Sat Sep 17, 2011 8:09 pm Post subject: isCached problems with template hierarchy (extends:) |
|
|
Hello to the Smarty community,
I'm posting here regarding an issue i'm having with caching and complex hierarchical templates.
I've been implementing a theme / view hierarchical templating system on my latest project using Smarty 3.
Say I've got a master theme template located in /templates/master.tpl, and this template contains {block} tags.
I then have a view template located in <abspath>/views/view.tpl with definitions for the master blocks.
I'm displaying the whole using :
Code: |
$mySmartyInstance->display('extends:master|<abspath>/views/view.tpl', 'cacheID');
|
Everything is working fine. Except caching tests.
I'm using the following smarty options :
Code: |
$this->caching = \Smarty::CACHING_LIFETIME_CURRENT;
$this->cache_lifetime = 3600;
$this->compile_check = false;
$this->debugging = true;
$this->force_compile = false;
|
My template hierarchy is surely cached because the debugging window shows only caching times like :
Code: |
<abspath>/views/view.tpl (compile 0.00000) (render 0.00000) (cache 0.00019)
|
But when I want to test the cache state for a template in my code to skip unnecessary SQL requests, it always returns false.
I've tried testing cache using :
Code: |
$mySmartyInstance->isCached('<abspath>/views/view.tpl', 'cacheID');
$mySmartyInstance->isCached('view.tpl', 'cacheID');
$mySmartyInstance->isCached('extends:master|<abspath>/views/view.tpl', 'cacheID');
|
But to no avail.
Any idea or thought on the question ?
Thank you,
Thibaut.
Last edited by BKcore on Mon Sep 19, 2011 3:59 pm; edited 1 time in total |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sun Sep 18, 2011 3:01 am Post subject: |
|
|
At dispay you used 'myCacheId' and at isCached 'cacheId'
This should work
Code: | $mySmartyInstance->isCached('extends:master|<abspath>/views/view.tpl', 'myCacheID'); |
|
|
Back to top |
|
BKcore Smarty n00b
Joined: 17 Sep 2011 Posts: 3
|
Posted: Mon Sep 19, 2011 3:58 pm Post subject: |
|
|
Sorry this was a typo in my post. It is of course the same ID. |
|
Back to top |
|
rodneyrehm Administrator
Joined: 30 Mar 2007 Posts: 674 Location: Germany, border to Switzerland
|
Posted: Mon Sep 19, 2011 6:45 pm Post subject: |
|
|
I tried your setup: Code: | $tpl = 'extends:f1/master.tpl|'. dirname(__FILE__) .'/templates/f2/child.tpl';
$cacheID = 'cacheID';
var_dump(
$smarty->isCached($tpl, $cacheID),
$smarty->display($tpl, $cacheID)
);
|
I got a [false, null] on the first and [true, null] on the second run. As expected.
(run against SVN trunk r4288). _________________ Twitter |
|
Back to top |
|
BKcore Smarty n00b
Joined: 17 Sep 2011 Posts: 3
|
Posted: Thu Sep 22, 2011 6:14 pm Post subject: |
|
|
Updating Smarty to its latest revision seems to have fixed it.
It's now fully working.
Thank you for your help. |
|
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
|