Author Topic: Content plugin support/fix for joomla 1.6 or later  (Read 6482 times)

manchumahara

  • Beginner
  • *
  • Posts: 3
Content plugin support/fix for joomla 1.6 or later
« on: December 27, 2011, 09:52:10 am »
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

Code: [Select]
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
Code: [Select]
// 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
Code: [Select]
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

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 28154
  • Always on vacation
    • Jenkin Hill Internet
Re: Content plugin support/fix for joomla 1.6 or later
« Reply #1 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
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VirtueMart 3.8.9.10473 on Joomla 3.9.28 PHP 7.4.14

manchumahara

  • Beginner
  • *
  • Posts: 3
Re: Content plugin support/fix for joomla 1.6 or later
« Reply #2 on: December 28, 2011, 16:14:07 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

  • Beginner
  • *
  • Posts: 7
Re: Content plugin support/fix for joomla 1.6 or later
« Reply #3 on: January 14, 2012, 21:25:56 pm »
 ;D now my joomla plugins work in V2 & J1.7
many many  thanks, manchumahara !!!
this modification should be in next VM version


Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10101
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Content plugin support/fix for joomla 1.6 or later
« Reply #4 on: January 15, 2012, 21:16:15 pm »
Thank you for this hint,
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.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

manchumahara

  • Beginner
  • *
  • Posts: 3
Re: Content plugin support/fix for joomla 1.6 or later
« Reply #5 on: February 19, 2012, 18:16:56 pm »
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

Thank you for this hint,
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.