Writing an OPC extension

Writing an OPC extension

Postby admin » Wed Nov 23, 2011 4:04 pm

This is a simplified guide for external extension makers to make our components cross compatible.

Our component uses own order handler in file ps_onepage which might lead in some instances to incompatibilities with 3rd party extensions especially if they use encoded files and we can't create a merged file or an extension. This guide describe how to call and create an OPC extension.

This line when run from ps_onepage.php will include all files in these directories:
/components/com_onepage/ext/EXTENSION_NAME/ps_onepage.php/include.php

to trigger it run this code:
Code: Select all
include_once(JPATH_ROOT.DS.'components'.DS.'com_onepage'.DS.'ext'.DS.'extension.php');


// this will init extHelper class before loading a specific function
Code: Select all
$extHelper = new opExtension();


This lile will run function atConstructor($params, &$d) in class opExtNameoftheextensionFilefromwhichitiscalled (example: opExtFreeshippcPs_onepage )
Code: Select all
$ret = $extHelper->runExt('atConstructor', '', '', $d);


$ret is false when no ext triggered or not found
$ret can be a cumulated results from various extensions -> if bool it is summed with &&, if array, it is summed as array and if string it is summed as string. It is recommended to use parameter as refenrence instead of return value
$params is the first parameter at function definition which contains extension specific parameters

A proper extension must have a /components/com_onepage/ext/Nameofthextension/validate.php file with $load=true; to be triggered. This is used to check if external components such as paypal new api is installed.

If you need to modify any OPC files with $extHelper->runExt, you can send me a modified OPC file and i will incorporate it into my component's standard version

General structure of an extension
/components/com_onepage/ext/Nameoftheextension
/components/com_onepage/ext/Nameoftheextension/validate.php (must contain $load=true; to trigger extension)
/components/com_onepage/ext/Nameoftheextension/enabled. // if you check to enable the extension with OPC configurator, this file will be automatically created and the extension can be run, if this file does not exists the extension is disabled (i decided to use files instead of database)
/components/com_onepage/ext/Nameoftheextension/extension.xml //xml specification according to VM theme xml config (joomla 1.0) -> this will get upgraded to joomla 1.5+ spec later on -> you can set name, description, author, etc in this xml file
/components/com_onepage/ext/Nameoftheextension/extension.config.php // this file is automatically created at the backend with proper parameters
/components/com_onepage/ext/Nameoftheextension/filename_from_which_runExt_is_triggered.php/include.php // this file is included as described above
/components/com_onepage/ext/Nameoftheextension/filename_from_which_runExt_is_triggered.php/extension.php // this is class file and must contain a unique class name as described above

Don't foget to put index.html into each directory according to Joomla specification.

Best Regards,
Stan Scholtz
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Return to One Page Checkout for Virtuemart 1.1.x

cron