Developing a module or plugin for Virtuemart 2 » History » Version 6
Max Milbers, 02/14/2012 06:00 AM
1 | 1 | Max Milbers | h1. Developing a module or plugin for Virtuemart 2 |
---|---|---|---|
2 | |||
3 | When you want to develop your own extension for virtuemart, then this hints should you help to get started: |
||
4 | |||
5 | Use |
||
6 | @if (!class_exists( 'VmConfig' )) require(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'config.php');@ |
||
7 | to load the configuration object in your extension. Then use |
||
8 | |||
9 | 5 | Max Milbers | @$config = VmConfig::loadConfig();@ |
10 | 1 | Max Milbers | |
11 | to load the configuration values, you can then easily access them with |
||
12 | |||
13 | @VmConfig::get('yourVariable','default');@ |
||
14 | |||
15 | 2 | Max Milbers | After loading the VmConfig you should always use the vm path constants to access files |
16 | |||
17 | @JPATH_VM_SITE = JPATH_ROOT.DS.'components'.DS.'com_virtuemart' ); |
||
18 | JPATH_VM_ADMINISTRATOR = JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart' );@ |
||
19 | |||
20 | For performance reasons you should always use the |
||
21 | |||
22 | @if (!class_exists( 'MyClass' )) require (JPATH_VM_ADMINISTRATOR.DS....)@ |
||
23 | |||
24 | construction, dont use require_once |
||
25 | 1 | Max Milbers | |
26 | 6 | Max Milbers | Loading and instancing a model is very easy in Vm, just use |
27 | $mynameModel = VmModel::getModel('myname'); |
||
28 | |||
29 | for example: $currencyModel = VmModel::getModel('currency'); |
||
30 | |||
31 | 1 | Max Milbers | When you want to access the js used in vm then load them with |
32 | |||
33 | 4 | Max Milbers | @$config->jQuery(); |
34 | $config->jVm();@ |
||
35 | 1 | Max Milbers | |
36 | or for the css use |
||
37 | 4 | Max Milbers | @$config->cssSite();@ |
38 | 1 | Max Milbers | |
39 | 5 | Max Milbers | For shipment, payment, or other plugin development please look here [[Plugin system]] or for modules here [[Modules system]] |