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

Content plugin support/fix for joomla 1.6 or later

Started by manchumahara, December 27, 2011, 09:52:10 AM

Previous topic - Next topic

manchumahara

I see virtuemart2 is compatible with joomla 1.6 , hope for 1.7 too. I see there is a issue for content plugin compatibility for vm2 in joomla1.6. Then checked the vm2 code where the plugin event if fired. I see the plugin trigger method is not compatible with 1.6 content plugin structure, the hook name is for old  joomla 1.5 series

note: paths are windows style

folder  components\com_virtuemart\views\productdetails  open file view.html.php line 97

if ( VmConfig::get('enable_content_plugin',0)) {
// add content plugin //                   
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
$product->text = $product->product_desc;
$params = "";
                        //var_dump($product);
$results = $dispatcher->trigger('onPrepareContent',array (& $product, & $params, 0));
$product->product_desc = $product->text;
}


Here the content plugin trigger event is for 1.5 series. from joomla 1.6 the "onContentPrepare" and also takes one more input.

So for line 104 there should be a check for joomla version and add conditional event hook.

It's not hard to check the joomla version. sample code used in k2 component
// Determine Joomla! version
if(version_compare( JVERSION, '1.6.0', 'ge' )) {
define('K2_JVERSION','16');
}
else {
define('K2_JVERSION','15');
}



here is how the code can be for both 1.5 and 1.6+ content plugins support
if ( VmConfig::get('enable_content_plugin',0)) {
// add content plugin //     
                        // Determine Joomla! version
                        if(version_compare( JVERSION, '1.6.0', 'ge' )) {
                                define('VMJ2_JVERSION','16');
                        }
                        else {
                                define('VMJ2_JVERSION','15');
                        }
                       
                       
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
$product->text = $product->product_desc;
$params = "";
                        //var_dump($product);
                        if(VMJ2_JVERSION=='16'){
                            $results = $dispatcher->trigger('onContentPrepare',array ('com_virtuemart.productdetails',& $product, & $params, 0));
                        }
                        else{
                            $results = $dispatcher->trigger('onPrepareContent',array (& $product, & $params, 0));
                        }
                       

$product->product_desc = $product->text;
}



thank you

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

manchumahara

Quote from: jenkinhill on December 27, 2011, 14:09:51 PM
Use VM2 in either Joomla 1.5.x or 1.7.x not with 1.6 which is past end of life.

http://forum.virtuemart.net/index.php?topic=95234.0

If you look at the virtuemart code I mentioned in first post, it's content plugin trigger function/code is not also joomla1.7 compatible. thank you for your off topic comment.

mrajko

 ;D now my joomla plugins work in V2 & J1.7
many many  thanks, manchumahara !!!
this modification should be in next VM version


Milbo

#4
Thank you for this hint,
Quote from: manchumahara on December 28, 2011, 16:14:07 PM
Quote from: jenkinhill on December 27, 2011, 14:09:51 PM
Use VM2 in either Joomla 1.5.x or 1.7.x not with 1.6 which is past end of life.

http://forum.virtuemart.net/index.php?topic=95234.0

If you look at the virtuemart code I mentioned in first post, it's content plugin trigger function/code is not also joomla1.7 compatible. thank you for your off topic comment.

but I dont wanna be rude, because you did a good job, but hmmm... (maybe you should not mention k2 here)

You wrote this post at 27.12. But vm1.9.8 was already compatible to joomla 1.7. Jenkinhill did exactly his moderator job, he is not a programmer, so he just sees that you comment an outdated version. He does not know that the changes implement in j1.6 are most likely also in j1.7. So from his point of view, he did not a offtopic answer, it fits. So and now I add version check.

and you use these constants, which are not needed, or you wanna point a bit on the fact that we should use a constant, instead of the version_compare to gain speed. I think it is neglectable, but it is not out of the world.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

manchumahara

1. I mentioned k2 as an example. I am not one of them, i just wanted to make my social share plugin compatible with VM2 and found it's not working as we write the content hook for 1.6 or 1.6+.

2.@jenkinhill   I am sorry for being rude.

Thank you

Quote from: Milbo on January 15, 2012, 21:16:15 PM
Thank you for this hint,
Quote from: manchumahara on December 28, 2011, 16:14:07 PM
Quote from: jenkinhill on December 27, 2011, 14:09:51 PM
Use VM2 in either Joomla 1.5.x or 1.7.x not with 1.6 which is past end of life.

http://forum.virtuemart.net/index.php?topic=95234.0

If you look at the virtuemart code I mentioned in first post, it's content plugin trigger function/code is not also joomla1.7 compatible. thank you for your off topic comment.

but I dont wanna be rude, because you did a good job, but hmmm... (maybe you should not mention k2 here)

You wrote this post at 27.12. But vm1.9.8 was already compatible to joomla 1.7. Jenkinhill did exactly his moderator job, he is not a programmer, so he just sees that you comment an outdated version. He does not know that the changes implement in j1.6 are most likely also in j1.7. So from his point of view, he did not a offtopic answer, it fits. So and now I add version check.

and you use these constants, which are not needed, or you wanna point a bit on the fact that we should use a constant, instead of the version_compare to gain speed. I think it is neglectable, but it is not out of the world.