News:

Looking for documentation? Take a look on our wiki

Main Menu

Content plugin broken in product_desc

Started by zanardi, March 21, 2014, 11:07:43 AM

Previous topic - Next topic

zanardi

Using VirtueMart 2.0.26d. I think content plugin processing is broken for product_desc on product_details view.

Here's the code from frontend/views/productdetails/view.html.php (lines 125-127)


if (VmConfig::get('enable_content_plugin', 0)) {
shopFunctionsF::triggerContentPlugin($product, 'productdetails','product_desc');
}


And here's the code from frontend/helpers/shopfunctionsf.pgp (lines 698-725)


static function triggerContentPlugin(  $article, $context, $field) {
// add content plugin //
$dispatcher =   JDispatcher::getInstance ();
JPluginHelper::importPlugin ('content');
$article->text = $article->$field;
jimport ('joomla.html.parameter');
$params = new JParameter('');

if (JVM_VERSION === 2) {
if (!isset($article->event)) {
$article->event = new stdClass();
}
$results = $dispatcher->trigger ('onContentPrepare', array('com_virtuemart.'.$context, &$article, &$params, 0));
// More events for 3rd party content plugins
// This do not disturb actual plugins, because we don't modify $vendor->text
$res = $dispatcher->trigger ('onContentAfterTitle', array('com_virtuemart.'.$context, &$article, &$params, 0));
$article->event->afterDisplayTitle = trim (implode ("\n", $res));

$res = $dispatcher->trigger ('onContentBeforeDisplay', array('com_virtuemart.'.$context, &$article, &$params, 0));
$article->event->beforeDisplayContent = trim (implode ("\n", $res));

$res = $dispatcher->trigger ('onContentAfterDisplay', array('com_virtuemart.'.$context, &$article, &$params, 0));
$article->event->afterDisplayContent = trim (implode ("\n", $res));
} else {
$results = $dispatcher->trigger ('onPrepareContent', array(& $article, & $params, 0));
}
$article->$field = $article->text;
}


You can see for yourself that $article is not passed as a reference nor it's returned, so of course it will never get modified.

Solution is to alter the signature of the method like this:


static function triggerContentPlugin( &$article, $context, $field) {


Hope this helps.
--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter

Milbo

Thank you very much zanardi. I really wonder how this code could work before. But we also have threads in which the content plugin were blocking the pdf creation. Anyway added this way in vm2.5.5, please test.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/