janrop
janrop

Reputation: 301

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.index.tpl');

Upvotes: 0

Views: 459

Answers (1)

Pekka
Pekka

Reputation: 449613

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

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

Upvotes: 2

Related Questions