Friday, 23 November 2012

Why $smarty->is_cached() emits fatal error in smarty 3?

When we use the cache function is_cached() in smarty version 3 it'll emit fatal error as shown below:

Fatal error: Uncaught exception 'SmartyException' with message 'unknown method 'is_cached''

I've been searched all over the internet and couldn't find out the solution why it shows this error in latest version alone. But in documentation it is not deprecated. Then what the hell is going on with smarty 3.

Finally I found out that they changed the syntax of the function is_cached() in latest version.
According to latest version we have to declare it as isCached()

if(!$smarty->isCached("post.tpl",$postid)){
 $smarty->assign('image_url',$img_path);

$smarty->display('post.tpl',$postid);

We have to give cache id($post_id) for the function isCached() to make it work.Thats It!! I hope it works for u!!

No comments:

Post a Comment