OpenCart OCMOD 和 VQMOD 修改系统 [英] OpenCart OCMOD and VQMOD Modification Systems

查看:150
本文介绍了OpenCart OCMOD 和 VQMOD 修改系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 OpenCart OCMOD 和 VQMOD 系统的新手.所以我需要一些帮助.我的问题是.

I am new to OpenCart OCMOD and VQMOD systems. So I need some help. My questions are.

  1. 据说OCMOD是OC2+默认系统.也有人说我们必须自己编写OCMOD.这是什么意思?如果 OCMOD 带有 OC2+.那我们为什么要自己写呢?如果 OCMOD 是 OC+2 的默认部分.那么我们在OC 3.0.2.0中哪里可以找到呢?

  1. It is said that OCMOD is OC2+ default system. It is also said we have to write our OCMOD ourselves. What does it mean? If OCMOD comes with OC2+. Then Why we need to write it ourselves? If OCMOD is deault part of OC+2. Then where can we find it in OC 3.0.2.0?

如何使用 OCMOD 在 OpenCart 中进行更改而不影响核心文件?

How to use OCMOD to make changes in OpenCart without affecting core files?

在安装新的 OCMOD.zip 或 OCMOD.xml 和 VQMOD.zip 或 VQMOD.xml 后,如何在不删除这些更改的影响的情况下,在不安装 OCMOD 或 VQMOD 的情况下删除已在 OpenCart 核心文件中进行的更改.

How to remove changes already made without installing OCMOD or VQMOD in OpenCart core files after installing new OCMOD.zip or OCMOD.xml and VQMOD.zip or VQMOD.xml without removing the effect of that changes.

如何使用 OCMOD 或 VQMOD 恢复升级版 OpenCart 中所做的更改?

How to restore changes made in OpenCart in upgraded version using OCMOD or VQMOD?

如果安装了新的 OCMOD 或 VQMOD,它是否会删除 OpenCart 核心文件中已经进行的所有更改?

If new OCMOD or VQMOD is installed, does it removes all the changes already made in core files of OpenCart?

推荐答案

我们第一次讨论 一般 OCMOD 和 VQMOD 逻辑.这次我来介绍一下OCMOD的工作经历(VQMOD的工作原理大体相同,已经过时了,所以省略了).OCMOD 本身是一个引擎(从 2.X 开始就内置于 OpenCart 中).我们需要在这个引擎中放置一个指令以使其工作.指令文件采用 XML 格式并具有特定名称,例如 my_file.ocmod.xml,其中需要以 .ocmod.xml 结尾.

First time we were talking about general OCMOD and VQMOD logic. This time I'll describe the OCMOD working experience (VQMOD works mostly the same and is outdated, so I will omit it). OCMOD itself is an engine (built in OpenCart since 2.X). We need to place in this engine an instructions to make it works. The instruction files are in XML format and has specific names, like my_file.ocmod.xml, where .ocmod.xml ending is required.

这里是一个 OCMOD 文件的例子

Here is an example of OCMOD file

<?xml version="1.0" encoding="utf-8"?>
<modification>
  <name>My OCMOD file</name>
  <code>my-ocmod</code>
  <version>1.0</version>
  <author>Me</author>
  <link>http://mywebsite.com</link>

  <file path="catalog/view/theme/default/template/common/header.twig">
    <operation>
      <search><![CDATA[<div id="top-links" class="nav pull-right">]]></search>
      <add position="before"><![CDATA[
        <div>Add Something</div>
      ]]></add>
    </operation>
  </file>  
  
  <file path="catalog/controller/common/header.php">
    <operation>
      <search><![CDATA[$data['name'] = $this->config->get('config_name');]]></search>
      <add position="replace"><![CDATA[
        $data['name'] = $this->config->get('config_name') . $this->document->getDescription();
      ]]></add>
    </operation>
  </file>  

</modification>

这里我们在 2 个不同的文件中有 2 个指令(操作)(我们也可以在单个文件中实现多个操作).在操作中,我们在原始核心文件中搜索一行代码,并在add标签中添加之前/之后或用tho代码替换它.这是 OCMOD 文件文档,可能对 .ocmod.xml 有所帮助 文件构建.

Here we have 2 instructions (operations) in 2 different file (we can implement multiple operations in a single file as well). In operation we are searching for a line of the code in original core file and add before/after or replace it with tho code in add tag. Here is OCMOD file documentation, might help with .ocmod.xml file building.

当您有 .ocmod.xml 文件时 - 您需要安装它.有两种不同的方法:

When you have .ocmod.xml file - you need to install it. There are two different ways to do it:

  1. /system 文件夹中插入文件并清除缓存.
  2. Extension - Installer 的管理面板中安装您的 .ocmod.xml 文件和 清除缓存.这种情况比较好管理.您可以在扩展 - 扩展中找到您的 OCMOD 文件.这些不是文件,而是一个数据库条目.要在安装后编辑它们,您可能需要 OCMOD 编辑器.
  1. Insert file in /system folder and clear cache.
  2. In admin panel in Extension - Installer install your .ocmod.xml file and clear cache. This case is better to manage. You can find your OCMOD files in Extension - Extension. These are not files, but a database entry. To edit them after installation you may need OCMOD editor.

在某些情况下,您可以看到带有 install.xmlupload 文件夹的 .ocmod.zip 存档.它可以是带有 OCMOD 文件和附加文件的模块,在单个安装程序中编译.

In some cases you could see .ocmod.zip archive with install.xml and upload folder. It could be the module with OCMOD file and additional files, compiled in a single installer.

现在,当我们安装了带有操作 .ocmod.xml 的文件并清除了缓存时 - 系统会创建核心文件副本并将它们保存在 /system/storage/modifications/....如果我们从示例中获取代码 - 您会发现文件 /system/storage/modifications/catalog/view/theme/default/template/common/header.twig 包含来自 的已实施更改.ocmod.xml.

Now, when we have a file with operations .ocmod.xml installed and cache is cleared - system creates core files copies and keep them in /system/storage/modifications/.... If we take the code from the example - you will find file /system/storage/modifications/catalog/view/theme/default/template/common/header.twig with implemented changes from .ocmod.xml.

就是这样.OCMOD 就这么简单.一旦您安装了任何 .ocmod.xml 文件 - 该文件将保存在 OpenCart 中,并在每次缓存清理后执行操作.您在 .ocmod.xml 文件中进行了更改 - 清除缓存.安装新的 .ocmod.xml - 清除缓存.删除了一些旧的 .ocmod.xml - 清除缓存.

So that's it. OCMOD works as simple as this. As soon as you have installed any .ocmod.xml file - this file is keeps in OpenCart, and implement operations after every cache cleaning. You made changes in .ocmod.xml file - clear the cache. Installed new .ocmod.xml - clear the cache. Removed some old .ocmod.xml - clear the cache.

升级 OpenCart 版本后 - OCMOD 文件可能保持不变.但是如果它们不见了 - 只需重新安装它们(您应该在某处之前保存它们).

After upgrading OpenCart version - OCMOD files may stay untouched. But if they are gone - just install them again (you should save them before somewhere).

附言不同的 .ocmod.xml 文件会影响同一个核心文件.这绝对没问题.

P.S. Different .ocmod.xml files can affect on the same core file. This is absolutely OK.

这篇关于OpenCart OCMOD 和 VQMOD 修改系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆