Things to take care while making OCMOD file:
  1. File extension must be either .ocmod.zip or .ocmod.xml.
  2. Upload from admin section, Admin>>Extensions >> Extension Installer, Upload the .xomod.zip or .ocmod.xml file from here.
Now go to following link and download “Display all Products” module
You will find following ocmod example which shows how to show “All Products” links at the top menu bar.
For example:
OCMOD is a system that allows store owners to be able to modify their store by uploading a compressed file that contains XML, SQL and PHP files.
If a OCMOD is developed correctly it can modify how a users OpenCart store works without changing any of the core files. This means that if a modification is removed none of the original OpenCart files need to be restored or fixed.

OCMOD Files

OCMOD files can be upload via the opencart admin under:
Extensions / Extension Installer
For a OCMOD file to be uploaded the file extension must be either .ocmod.zip or .ocmod.xml. This is to avoid none OCMOD files from being uploaded to a store users admin.

File Structure

Example file structure for OCMOD compressed files.
  • upload
  • install.sql
  • install.php
  • install.xml

upload

All files under this directory will be uploaded to the to directory of your OpenCart installation.

install.sql

Add any create, drop, insert and update SQL quires here. Make sure each query ends with ;

install.php

If the modification requires any custom PHP code.

install.xml

The XML modification file.
You can view the documentation for this system below.

XML

This is the file that creates a virtual copy of any files that require changes. Use this system instead of overwriting any default installation files. Multiple modifications can be applied to the same file.
Example OCMOD file:

Tags

File

You can set multiple file locations by spiting up the file locations using commas. The modification system uses PHP function glob.
Example:
Direct file path.

Using braces allows for selecting multiple files and not having to repeat the code operation multiple times.

also allows braces

please note that all file paths must start with either admin, catalog or system. you can also use wildcard *

Search

Search code
Allowed Attributes
  • trim=”(true|false)”
  • regex=”(true|false)”
  • index=”(number)”
Example:

Add

The code to replace the search with.
Allowed Attributes
  • trim=”(true|false)”
  • position=”(Replace|Before|After)”
  • offset=”(number)”
(note position can not be used if regex is set to true in the search attribute).
Example

Regex
Allowed Attributes
  • limit=”(number)”
Example:

If you use regex you can not use attributes position, trim or offset as these are handled by the regular expression code you write. The limit attribute is still available.
If, for example, you want to change the 3rd ‘foo’ to ‘bar’ on the following line:

Run:

Result:

You can find more information about the regular expression PHP function OCMOD uses can be found here:
More information about regular expression can be found here:

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here