Caching problem with dynamic template folder
| From: | Ahmad Amran Kapi | Date: | Wed, 27 Feb 2002 21:11:45 +0000 |
| Subject: | Caching problem with dynamic template folder | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-2883@lists.php.net to get a copy of this message | ||
Hi all,
I've problem with caching when assigning dynamic template path, below
is my
function for getting template path
function return_tpl_path()
{
$tpl_path = XDOT_INCLUDE_ROOT .'/'. $GLOBALS['xdot_info']['flags']
['currentapp'].'/templates';
return $tpl_path;
}
where XDOT_INCLUDE_ROOT is my root path, $GLOBALS['xdot_info']['flags']
['currentapp'] will
return the value where i put the value in every page,
It means the template will be dynamic depends on the application..
if the GLOBALS['xdot_info']['flags']['currentapp'] =
"forum";
so the template file will be in /forum/templates
and GLOBALS['xdot_info']['flags']['currentapp'] = "news";
the template file will be in /news/templates
and so on...
I've extend the smarty class..
class smart extends Smarty {
var $template_dir;
function smart(){
$this->template_dir = return_tpl_path();
}
}//end of smart class
but the problem I've detect is when i want to use the is_cached function
$t = new smart;
$t->caching = true;
if(!$t->is_cached('index.tpl'))
{
echo "run this";
// or running the database query
}
$t->display('index.tpl');
the is_cache will return false value every time, looks like it's never
been cache by smarty. So it will run the echo "run this" no matter
what I've set to this variable, caching=true, compiled_check=false..
Any idea why this is happened..
p/s the above code is a simplified of my problem.. but still emulate
the same environment as I am..
thank you in advance..
r0kawa