<< Back to man.ChinaUnix.net


void is_cached(string template, [string cache_id])

This returns true if there is a valid cache for this template. This only works if caching is set to true.


Example 13-18. is_cached
例子 13-18. 是否已被缓存

$smarty->caching = true;

if(!$smarty->is_cached("index.tpl")) {
// do database calls, assign vars here
// 调用数据库,并对变量进行赋值


You can also pass a cache id as an an optional second parameter in case you want multiple caches for the given template.


Example 13-19. is_cached with multiple-cache template
例子 13-19. 多缓存模板的判断

$smarty->caching = true;

if(!$smarty->is_cached("index.tpl","FrontPage")) {
// do database calls, assign vars here