Use plugins, show modules anywhere in a VirtueMart page

It's a know fact between VirtueMart insiders, that you can use Joomla plugins in the product descriptions. For that you need to enable this by clicking a checkbox in VirtueMart's main configuration (VirtueMart Admin > Configuration > Global tab > Enable content mambots/plugins in descriptions? checkbox.)

But what if you want to use plugins elsewhere, in other spots of the VirtueMart pages? For example in some other spot of the product details page - let's say to insert an availability calendar module under the main product image?

Right, you can do it with a little code hack! Let's make our hands dirty with some PHP then!

The process is simple, let's say we published the module I talked above in the module position called "availabilitycalendar" so hopefully if we insert in the correct spot in the product details template the code

	{ loadposition availabilitycalendar}

the Joomla parsing engine will do the rest, and will show the module! Wrong presumption, the site will show the raw code, because the VirtueMart parsing engine will replace the plugin codes only in the product descriptions. And if we try to use the similar trick which works in most of Joomla components to show plugins anywhere will also fail - VirtueMart is a different beast...

But wait, the solution is here! VirtueMart has a function to force this. Let's replace the raw plugin code above with this:

echo vmCommonHTML::ParseContentByPlugins( '{ loadposition availabilitycalendar}' );

Bingo! the code is parsed! Simple, eh? Enjoy it! But be aware depending on where you use it - if not in template files, for example  - is qualifying as a core hack, so use at your own risk.

And don't buy me a beer, EekI prefer a Like, a Plus or a Share Wink.