News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Using VmExtendedPlugin

Started by Stephen Roberts, November 11, 2011, 23:00:03 PM

Previous topic - Next topic

Stephen Roberts

First of all, I'm using Joomla! 1.5.24 with the latest VM release 'M'. I've been playing around with using VmExtendedPlugin to build a custom control panel in the VM back-end and have come across a number of thoughts and questions.

I'm trying to add functionality to the back-end that is almost identical to VM Categories. I've built a model, controller, and view and added a menu item in the 'adminmenuentries' table. I want to load this view up with a plugin. Now for my thoughts/questions.

1. It appears that VmExtendedPlugin is not being loaded by VM. I have to add the following line at the top of my subclass of VmExtendedPlugin:

if (!class_exists( 'VmExtendedPlugin' )) require(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'vmextendedplugin.php');

Is this the intended behavior?

2. The constructor throws the following PHP error:

Fatal error: Access level to VmExtendedPlugin::$_name must be public (as in class JPlugin) in /var/www/html/imd-test/administrator/components/com_virtuemart/helpers/vmextendedplugin.php on line 117

To fix this, I had to change protected $_name = ''; to var $_name = '';

3. I'm not sure what best practice is, but I tried storing all of my files: model, controller, and views in the same folder as the plugin (/plugins/vmextended/myplugin). Unfortunately, VmController does not allow specification of the location of the view, so it's looking for the view in /administrator/components/com_virtuemart/views/. I had to change

public function __construct($cidName='cid') {
parent::__construct();


to

public function __construct($cidName='cid',$config=array()) {
parent::__construct($config);


in vmcontroller.php so that I can specify the 'view_path' in my controller subclass. Even if it's not best practice to store views in the plugins folder, VmController should offer the option to specify these parameters.

These are my observations. Should some of these issues be fixed? Am I approaching this problem the correct way? Any thoughts are appreciated!

Regards,

Stephen Roberts
Sell downloadable (virtual) products in VirtueMart 2 and deliver downloads via local server, Amazon S3, and more! http://www.digitollsoftware.com

Stephen Roberts

I forgot to mention another issue.

4. After fixing 1 and 2 in my previous post, I ran into this error:

Fatal error: Cannot unset string offsets in /var/www/html/imd-test/libraries/joomla/event/event.php on line 60

I tracked it down to admin.virtuemart.php and changed:

$results = $dispatcher->trigger('onVmAdminController', $_controller);

to

$results = $dispatcher->trigger('onVmAdminController', array($_controller));

The second parameter of JDispatcher::trigger() must be an array. I believe there is at least one other instance where trigger is called with an invalid second parameter.
Sell downloadable (virtual) products in VirtueMart 2 and deliver downloads via local server, Amazon S3, and more! http://www.digitollsoftware.com

alatak

Hi,

Yes u are rigth.
Fixed in revision 4694.
Txs for debugging :)

Stephen Roberts

Thanks! So is it bad practice to store my MVC in the same folder as the plugin? Should I store them in administrator/components/com_virtuemart?
Sell downloadable (virtual) products in VirtueMart 2 and deliver downloads via local server, Amazon S3, and more! http://www.digitollsoftware.com

Stephen Roberts

I've been working on this a little more. If you haven't already fixed it, we need to also be able to pass parameters to JModel (specifically for me to define the table_path parameter). So in VmModel.php please change:

public function __construct($cidName='cid'){
parent::__construct();


to

public function __construct($cidName='cid',$config=array()){
parent::__construct($config);


After I fixed that, I was finally able to get my VmExtendedPlugin to work properly! The only remaining issue is how to add the menu entry in virtuemart_adminmenuentries automatically. I'm in Joomla! 1.5.24 and plugins cannot run SQL on installation. Do you guys plan on adding a control panel to allow changing the VM menus?

Thanks!
Sell downloadable (virtual) products in VirtueMart 2 and deliver downloads via local server, Amazon S3, and more! http://www.digitollsoftware.com