阻止Smarty 2模板被缓存/编译
I have an issue with Smarty 2.6.9 caching, where I have a 2 templates called confirmation.tpl
which are both stored in different directories in my codebase.
However, when they are compiled they are compiled in a /cache/gb/
directory. For these two templates only I would like to prevent the compiling, and as such I have attempted to use the force_compile
member variable, however this is having no effect at all and the template is consistently cached.
The problem that this is presenting is that both confirmation.tpl
templates are being called (by separate code) on the same page, so one template is being used for both and is causing me problems.
Is there a way that I can prevent this template from being compiled and cached in this way?
I am passing a flag through to set "no_compile" for the "confirmation.tpl" template ONLY.
$this->obj = new Smarty;
$this->obj->caching = false;
$this->obj->cache_lifetime = 10;
$this->obj->compile_check = true;
$this->obj->template_dir = $this->tpl_path;
if ($this->no_compile) {
$this->obj->force_compile = false;
$this->obj->compile_check = false;
}
我有Smarty 2.6.9缓存的问题,我有一个名为 然而,当它们被编译时,它们被编译在 这提出的问题是相同 em>页面上的 有没有办法阻止以这种方式编译和缓存此模板? p>
\ n 我正在传递一个标志,仅为“confirmation.tpl”模板设置“no_compile”。 p>
confirmation.tpl的2个模板 code>,它们都存储在我的代码库中的不同目录中。 p>
/ cache / gb / code>目录中 。 对于这两个模板,我只想阻止编译,因此我尝试使用
force_compile code>成员变量,但这根本没有任何效果,并且模板始终被缓存。 p>
confirmation.tpl code>模板都被调用(通过单独的代码),所以 一个模板正在用于这两个模板并且导致我出现问题。 p>
$ this-> obj = new Smarty;
$ this-> obj-> caching = false;
$ this-> obj-> cache_lifetime = 10;
$ this-> obj-> compile_check = true;
$ this-> obj-> template_dir = $ this-> tpl_path;
if($ this-> no_compile){\ n $ this-> obj-> force_compile = false;
$ this-> obj-> compile_check = false;
}
code> pre>
div>
You can use different $compile_id
settings in display/fetch to get different physical files on disk (although I think Smarty should handle this automagically for you depending on the path). compile_id
can also be set for {include}
statements.
I'm not sure what the code you've pasted implies, but you will want to turn on force_compile
to make Smarty regenerate the template each time it is shown (it's false
by default).