How does the Opencart system/modifications folder function?

旧城冷巷雨未停 提交于 2019-12-07 17:04:42

问题


I am quite new to OC 2.X and I noticed as I was making changes to the site they werent appearing. When I went to change within the system/modifications folder the changes appeared. I assumed this folder was something new and nothing to do with vqmod. I thought it was a foler that would basically take priority over the core file.

Unfortunately when I installed a plugin it also rebuilt that folder so Ive lost all my changes (Im assuming thats what happened).

Im wondering how does this work overall? Must I make a new extension for every change I would like to make?

I cannot find a clear and concise explanation that explains it for a developers point of view.


回答1:


You can say that ocmod is same as vqmod but it differs in some ways and provided by default in opencart 2.0 and above version. You have to reset modification cache every time you make any changes to your module to see its effect. Like vqmod ocmod also generates cache files which are placed in modification folder. And files in this folder will get prior then the original one. As i think you were modifying files in modification file you might lose them if you clear modification cache from admin panel.

You can check system/startup.php file for more understanding.

// Modification Override
function modification($filename) {
if (!defined('DIR_CATALOG')) {
    $file = DIR_MODIFICATION . 'catalog/' . substr($filename, strlen(DIR_APPLICATION));
} else {
    $file = DIR_MODIFICATION . 'admin/' .  substr($filename, strlen(DIR_APPLICATION));
}

if (substr($filename, 0, strlen(DIR_SYSTEM)) == DIR_SYSTEM) {
    $file = DIR_MODIFICATION . 'system/' . substr($filename, strlen(DIR_SYSTEM));
}

if (is_file($file)) {
    return $file;
}

return $filename;
}


来源:https://stackoverflow.com/questions/33100072/how-does-the-opencart-system-modifications-folder-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!