开发者

Smarty ignores cache_id?

since I have dynamic elements in some of the sites I want to Cache with smarty, I figgured I would use the second parameter of smarty isCached() function with an Id like "parameter1.parameter2.parameter3". But for some reason smarty caches only once and then delivers the same page ignoring the parameters and dynamic content.

What could be the source of my problem?

Code:

.tpl file:

extends file="1_layout.tpl"}

{block name=title}domain.com - index{/block}

{block name=content} <html here> {/block}

.php file:

$view = new Smarty(); 
$view->caching = true; 

$id = "index_"; 
if(isset($_SESSION['userid'])){ 
   $id .= "loggedIn";
}else{
   $id .= "guest"; 
} 
$id .= $_COOKIE['filter']; 

if(!$view->isCached('1_index.tpl', $id)) {
   get and assign some data
} 

$view->display('1.i开发者_Python百科ndex.tpl');


You need to add the cache ID to the display call as well.

$view->display('1.index.tpl', $id); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜