VQmod writing for opencar (part 1)
While exploring the vQmod you always wanted to study and practice their own self-written a vQmod to use, I’m writing this article so that you can understand how to written vQmod correct syntax and fast absorbing what he had read and learn. For convenience in writing vQmod for OpenCart you can use a small tool following http://www.qualchem.co.nz/vqgen.php or http://www.opencart-extensions.co.uk / vqgen it will help you do not have to sit to type a series the long thin ngoàng code ^ ^. As in all a few examples using vQmod on OpenCart you have the opportunity to become familiar with some examples of vQmod, vQmod use a XML parser by default.
The syntax of the xml file that vQmod analysis has the following basic format:
<?xml version="1.0" encoding="UTF-8"?> <modification> <id>Replace 123 with ABC</id> <version>1.0.0</version> <vqmver>1.0.9</vqmver> <author>qphoria</author> <file name="relative/path/myfile.php"> <operation> <search position="replace"><![CDATA[ $var = '123'; ]]></search> <add><![CDATA[ $var = 'ABC'; ]]></add> </operation> </file> </modification>
Explains XML syntax
This is the highest level of *. XML each form only once power pair
This is the name used to provide descriptive information mod was written format.
Provides information about the version of the mod is in decimal format eg: 1.1.0
Provides version information minimum of VirtualQMod need to do, is formatted using
decimal example: 2.1.5
Provide information about the author of the mod, written format.
This is the name of the file to change the name of the file related to the index.php file
for example: catalog / controller / product / product.php
Paths are supported with an asterisk (*) to represent a flexible path each an asterisk (*) to represent
only one folder for example:
Code:
– Catalog / view / theme / * / template / product / product.tpl – catalog / view / theme / * / * / product / product.tpl – etc.
There may be many files need to be changed in a *. Xml
This is where the changes are taking place activities.
There may be a lot of changes in a file
Options:
“Error” is set to skip | logs | abort
skip skip all the other activities, not stored in the log (Error Log)
log like skip but save bug in the log
abort cancel to return to the default errors
This is the first step takes place activities. để bao bọc đoạn mã.”>Need to use the [CDATA [code]]> wrapper code.
(Mặc định)”>replace: used when you want to replace the search data with data in tags (Default)
vào trước dữ liệu tìm kiếm.”>before: used when you want to insert data in tags in front of the search data.
vào sau dữ liệu tìm kiếm.”>after: used when you want to insert data in tags to search for data.
lên trên cùng của file và bỏ qua dữ liệu tìm kiếm”>top: used when you want to insert data in tags to the top of the data file and ignore search
xuống dưới cùng của file và bỏ qua dữ liệu tìm kiếm”>bottom: used when you want to insert data in tags to the bottom of the data file and ignore search
all: replace all of the data files with data in tags
The “offset” attribute will work together with the location of the position assumed offset value is 2 (oifset = “2”):
lên trước dữ liệu tìm kiếm 2 dòng.”>If the value of the position before it will put data in tags up the data before looking for 2 lines.
xuống dưới dữ liệu tìm kiếm 2 dòng.”>If the value of the position is after, it will put the data in tags down search data 2 lines.
The “index”
Free time I’ll write next.
Here his is a Vqmod by writing your reference will make it easier to visualize:
VQMOD darks AUTO FILL SEO KEYWORD:
Dark’s AutoFill Field Seo Seo link OpenCart, rewrite the html link for OpenCart free (Free)
<modification> <id>Dark's Autofill SEO field (Category, Product, Information) 1.4.x - 1.5.x</id> <version>1.4.x - 1.5.x</version> <vqmver>1.2.3</vqmver> <author>Darkstorns Admonistrator theme4u.biz</author> - <file name="admin/view/template/common/header.tpl"> - <operation> - <search position="before"> - <![CDATA[ </head> ]]> </search> - <add> - <![CDATA[ <script type="text/javascript"> $(document).ready(function(){ var keyword = $("input[name=keyword]"); if(!keyword.val()){ $("input[name^='product_description'],input[name^='category_description'],input[name='name'],input[name^='information_description']").keyup(function(){ var SEOlink = $(this).val(); SEOlink = SEOlink.replace(/^\s+|\s+$/g, ''); // trim SEOlink = SEOlink.toLowerCase(); // remove accents, swap, etc var from = "ọẹạịụớđàáäâèéëêìíïîòóöôùúüûñcçčlľštžýnrrd·ạảãầấậẩẫăắằẳẵặ_ịỉĩ/ọỏõôồốộổỗơờởợởỡ;ẹẻẽềếệểễ:ụủũưừứựửữ,ỵỷỹỳ"; var to = "oeaiuodaaaaeeeeiiiioooouuuuncccllstzynrrd--aaaaaaaaaaaaaa-iii-ooooooooooooooo-eeeeeeee-uuuuuuuu-yyyy"; for (var i=0, l=from.length ; i<l ; i++) { SEOlink = SEOlink.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i)); } SEOlink = SEOlink.replace(/[^a-z0-9 -]/g, '') // remove invalid chars .replace(/\s+/g, '-') // collapse whitespace and replace by - .replace(/-+/g, '-'); // collapse dashes // return SEOlink; keyword.val(SEOlink); }); } }); </script> ]]> </add> </operation> </file> </modification>