Plugins tips and tricks

on .

programmin joomla pluginsI'm reading the book "Programming Joomla Plugins" by our friend Jisse Reitma of Yireo.

As expected, many topics are already familiar in GiBiLogic, but I'm also learning a few cool new tricks.

Here's some bits that I found most interesting.

If you're really into plugin development you should probably buy the book yourself.


Fix conflict between AddThis plugin and VirtueMart invoice generation

on .

If you experience blank page issues when generating a PDF invoice with VirtueMart 2, a possible cause could be the presence of the AddThis content plugin.

As a quick test, disable the content plugin and see if the invoice generation works again.

If you can confirm that is the issue, you may be interested in the following fix.


The AddThis content plugin add social sharing buttons, so basically - like many content plugins - add HTML to the document.

To add script, CSS and other custom tags, it correctly uses the JDocument object. E.g.

$doc = JFactory::getDocument();
$doc->addCustomTag('<script type="text/javascript" src="'. $this->pageProtocol . '://"></script>');

Problem is, it does not check anywhere if the current document is in PDF format (i.e. JDocumentPDF) in which case most methods are not available and produce a fatal error.


A quick fix is to check the document type. E.g.

$doc = JFactory::getDocument();
if (get_class($doc) == 'JDocumentPDF') return true;
$doc->addCustomTag('<script type="text/javascript" src="'. $this->pageProtocol . '://"></script>');

In version 2.0.1 of the plugin I had to add the check twice, add the beginning of createAddThis and appendAddThisScript methods.

Future versions 

We  reported the issue to the developers and hopefully the fix will be included in future versions of this excellent content plugin.