php 在 OpenCart 3 中为开发禁用模板缓存
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45220327/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Disable template caching for development in OpenCart 3
提问by Rajat Jain
I am making changes in my theme templates in OpenCart 3. Due to template caching I have to clear cache every time under "storage/cache" directory. It is very annoying when working and previewing changes frequently during development. Please provide some solution how we can configure caching according to production and development environment.
我正在 OpenCart 3 中更改我的主题模板。由于模板缓存,我每次都必须在“存储/缓存”目录下清除缓存。在开发过程中频繁工作和预览更改时非常烦人。请提供一些解决方案,我们如何根据生产和开发环境配置缓存。
Note: I have already searched for solutions online but there is no solution related to template caching. Solutions are available to disable image caching but "Image Caching" and "Template Caching" are different features provided in Opencart.
注意:我已经在网上搜索了解决方案,但没有与模板缓存相关的解决方案。解决方案可用于禁用图像缓存,但“图像缓存”和“模板缓存”是 Opencart 中提供的不同功能。
回答by Scott C Wilson
You might need to upgrade to a more recent version of OpenCart3 - the first one (3.0.0.0) didn't have a way of doing this in the GUI.
您可能需要升级到更新版本的 OpenCart3 - 第一个版本 (3.0.0.0) 无法在 GUI 中执行此操作。
More recent versions, such as 3.0.2.0, have a gear on the admin dashboard. Click the gear and you get options to disable caching.
更新的版本,例如 3.0.2.0,在管理仪表板上有一个齿轮。单击齿轮,您将获得禁用缓存的选项。
回答by Rupak Nepali
Another way to do this: Open to system\library\template\Twig\Cache\Filesystem.php, find following lines of code
另一种方法:打开system\library\template\Twig\Cache\Filesystem.php,找到以下几行代码
public function load($key)
{
if (file_exists($key)) {
@include_once $key;
}
}
Comment out as in the following code:
注释掉如下代码:
public function load($key)
{
// if (file_exists($key)) {
// @include_once $key;
// }
}
This will remove the template cacheof the twig and recreate every time, once development is over you have to remove the comment.
回答by Randall Klassen
Opencart Version 3.0.2.0 I was having same problem, try working in theme editor or the actual raw twig file, after an hour or two i tried this it worked.
Opencart 版本 3.0.2.0 我遇到了同样的问题,尝试在主题编辑器或实际的原始树枝文件中工作,一两个小时后我尝试了它。
Delete the changes in theme editor and got back editing actual twig file my screen shot
删除主题编辑器中的更改并重新编辑实际的树枝文件 我的屏幕截图
回答by Pavan Mehta
You can also do this from CODE directly if you have the access. Go to this file path below via ftp or cPanel:
如果您有访问权限,您也可以直接从 CODE 执行此操作。通过 ftp 或 cPanel 转到以下文件路径:
system\library\template\Twig\Environment.php
Find
找
$this->debug = (bool) $options['debug'];
Replace:
代替:
$this->debug = (bool) true;
回答by billynoah
Scott's answer is best but in case it's not available due to version or you want to disable it programmatically you can do this anywhere before the twig is rendered:
Scott 的答案是最好的,但如果由于版本原因它不可用,或者您想以编程方式禁用它,您可以在渲染树枝之前的任何地方执行此操作:
$this->config->set('template_cache', false);
回答by john
I think you edit the template as the path: Design->Theme Editor before.
我认为您之前将模板编辑为路径:Design->Theme Editor。
Clear all of the date in the oc_theme data table of your database.
清除数据库 oc_theme 数据表中的所有日期。