Poll
Do you like vQmod
View Poll Results
Shopping Cart
0 items
 

How to install vQMod

Quick instructions

  1. Download the latest version of vQMod
  2. Backup your OpenCart files & folders
  3. Extract the folders contained in the archive and upload the folder 'vqmod' which is within the upload directory to the root of your OpenCart directory
  4. Edit the index.php in the root of your OpenCart directory and within the admin folder

    From this:

    // Startup

    require_once(DIR_SYSTEM . 'startup.php');

    // Application Classes

    require_once(DIR_SYSTEM . 'library/customer.php');

    require_once(DIR_SYSTEM . 'library/currency.php');

    require_once(DIR_SYSTEM . 'library/tax.php');

    require_once(DIR_SYSTEM . 'library/weight.php');

    require_once(DIR_SYSTEM . 'library/length.php');

    require_once(DIR_SYSTEM . 'library/cart.php');

    To this:

    //VirtualQMOD

    require_once('./vqmod/vqmod.php');

    $vqmod = new VQMod();

    // Startup

    require_once($vqmod->modCheck(DIR_SYSTEM . 'startup.php'));

    // Application Classes

    require_once($vqmod->modCheck(DIR_SYSTEM . 'library/customer.php'));

    require_once($vqmod->modCheck(DIR_SYSTEM . 'library/currency.php'));

    require_once($vqmod->modCheck(DIR_SYSTEM . 'library/tax.php'));

    require_once($vqmod->modCheck(DIR_SYSTEM . 'library/weight.php'));

    require_once($vqmod->modCheck(DIR_SYSTEM . 'library/length.php'));

    require_once($vqmod->modCheck(DIR_SYSTEM . 'library/cart.php'));

    Note for the index.php within the admin folder you will need to ensure the path is correct i.e. require_once('../vqmod/vqmod.php'); 

  5. Upload vQMod xml script files to the 'vqmod/xml' folder located in your root directory

From vQmod.com

vQmod is called by simply including the vqmod.php file near the top of your main index.php file, before any other includes are called. You want vQmod to be loaded before everything else so that it can be used to mod everything else. It obviously can't modify files that are loaded before it. Additionally, you will want to instantiate the vqmod class so that it can be referenced throughout the rest of the system.

You will want to make sure that any of the following functions [include(), include_once(), require(), require_once()] called from within the index.php are changed manually. The rest can be done with a vQmod script.

For example, if the top of your index.php file looks like this:

<?php
// Version
define('VERSION', '1.2.3');

// Startup
require_once('startup.php');
require_once('funcs/db.php');
require_once('funcs/lang.php');
...
...
?>

You would change it to:

<?php
// Version
define('VERSION', '1.2.3');

//vQmod
require_once('vqmod.php');
$vqmod = new VQMod();

// Startup
require_once($vqmod->modCheck('startup.php'));
require_once($vqmod->modCheck('funcs/db.php'));
require_once($vqmod->modCheck('funcs/lang.php'));
...
...
?>

Now, there may be multiple places throughout multiple files that the include functions are called, this does not mean you need to edit each of those files to make this change. Typically the main index.php file in a project does the loading for the rest of the files. This means if the include is called from the index.php file, you will need to change it manually, but if the file that gets included also has other included files, you can actually use a vQmod script to pre-mod those files. (Say wha?!) That's right, you can actually use a vQmod script to prepare the project to run other vQmod scripts.

For example:

In the above example, lets say that the funcs/db.php file has 3 more include function calls for other files. Since you are already called modCheck() on the include function that loads the db.php file, You can have a vQmod script that runs on that file to add the $vqmod->modCheck() to any other includes in that file, either by regex or string search/replace. So you only need to manually add it to the main "hub" and let a script handle the rest. Take a look at the existing platform scripts on the Scripts page for more examples.

You would change only those 3 places manually to include the modCheck() function. You would then create a script to add the $vqmod->modCheck() to any other includes/requires inside the funcs/db.php file. This file would then be your base or "core" script that always fires to setup the rest of the system. If you'd like to share, I appreciate working "core" scripts to be shared here so they can be made available to other people using that platform and make vQmod even easier for them to use right away.

 

Additional Parameters and Information

EXAMPLES
There is an /examples/ folder with some simple mods included in the zip, separated by platform. 
Copy the xml files into your /vqmod/ directory to see them work for the designated platform.
Their file names should explain their function.



ABILITIES & LIMITATIONS
1. VirtualQMod is designed to work with any php platform and so it gets called near the top of the index.php file manually.
This is the only file that it can't mod. All other files that are loaded from the index.php as controllers or included/required should be "VQModdable"!
This exludes stylesheets and scripts as they are rendered via the browser file itself, however, you CAN change which stylesheet is loaded in the template file.

2. The <search> parameter is currently limited to single line searches but by using the offset attribute you can blindly include multiple lines.
The <add>, however, can be multiple lines.


ADDITIONAL CONFIGURATION
VQMod offers additional configuration options. Be sure you understand them be fore using them:

- $vqmod->useCache = TRUE;
  If you have an exceptionally large number of mods on your site or just want to reduce any potential of performance loss,
  this will reuse the previously generated modified files, instead of regenerating the files on every page load.
  Newly added xml mods will still take affect on unmodded source files, but for any modded source files that were already 
  generated and exist in the \vqcache\ folder, will not be regenerated until $useCache is set to FALSE, or simply delete
  that file from the \vqcache\ folder to have it regenerated. Best practice when using $useCache would be to simply delete
  all files from the \vqcache\ folder whenever adding a new mod. This way you are sure that the new mod took effect and the
  cache will have all the latest changes. Set this by adding this line below the vqmod class object creation.
  (default: FALSE)
    
- $vqmod->logging = FALSE;
  This will disable logging for debugging and monitoring all the changes occurring to the files. 
  (default: TRUE)
  
- $this->protectedFilelist = './vqmod/vqprotect.txt';
  If you want to prevent some files from being modded for security puporses, You can create a file named "vqprotect.txt" in your root path.
  Here you can specify files (one per line) that will be skipped if a vqmod tries to alter it.
  Use the same relative path format as the "name" attribute in the <file> tag (e.g. catalog/controller/product/product.php)

- $virtualMode = FALSE;
  While the base concept of this mod is to "Virtually modify" the source files, it is quite easy to allow the source files to actually be modified.
  This obviously defeats the whole purpose of the tool and I DO NOT RECOMMEND USING IT. 
  I've set the code to rename "*.xml" files to "*.xml_NOVIRT" to avoid duplicating the modification over and over in the same file and alert which modfiles have been applied permanently. You can only change this manually in the vqmod.php code. I do not allow a method of setting it from the object for security reasons.