How to Enable Joomla Content Plugins in Virtuemart 2.x Categories Description
Many of you wish to add videos from YouTube, Image Galleries, Tabs and other elements to your virtuemart parent category, but unfortunately this option is only available for Products Description (in Virtuemart 2 and above), here's how to make this possible.
Pre-requisites
- Joomla 2.5.x
- Virtuemart 2.x
- FTP Client (Filezilla)
- PHP Editor (Notepad++)
As a first step, you need to enable this functionality which can be found in Virtuemart's core configurations:
- Login to your Joomla! Backend
- Go to Components > Virtuemart > Configuration
- On the Shop Page, tick the option that says "Enable Joomla Plugin"
- Save & Close.
By doing this, you are now able to call and parse custom Joomla plugins into Virtuemart's product description.
The next step is hard coding this functionality to the category description:
- FTP to your server (by using Filezilla or any other desktop/mobile client)
- Go to your /public_html//components/com_virtuemart/views/category/view.html.php and download it (Don't forget to create a backup copy of the file, since you're going to add your custom code to it).
- Open view.html.php in your favorite PHP editor (Notepad++, Dreamweaver or any other desktop/mobile client)
- Insert the following code snippet on line 151:
// add content plugin //
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
$category->text = $category->category_description;
jimport( 'joomla.html.parameter' );
$params = new JParameter();
if(JVM_VERSION === 2 ) {
$results = $dispatcher->trigger('onContentPrepare', array('com_virtuemart.category', &$category, &$params, 0));
// More events for 3rd party content plugins
// This do not disturb actual plugins, because we don't modify $product->text
$res = $dispatcher->trigger('onContentAfterTitle', array('com_virtuemart.category', &$category, &$params, 0));
$category->event->afterDisplayTitle = trim(implode("\n", $res));
$res = $dispatcher->trigger('onContentBeforeDisplay', array('com_virtuemart.category', &$category, &$params, 0));
$category->event->beforeDisplayContent = trim(implode("\n", $res));
$res = $dispatcher->trigger('onContentAfterDisplay', array('com_virtuemart.category', &$category, &$params, 0));
$category->event->afterDisplayContent = trim(implode("\n", $res));
} else {
$results = $dispatcher->trigger('onPrepareContent', array(& $category, & $params, 0));
}
$category->category_description = $category->text;
Save the file and re-upload view.html.php to the same destination and voila! you're done.
You can test your newly added code by going to your website's Joomla Backend > Components > Virtuemart > Products > Product Categories, and create / edit a category and attach to it any plugin related call (e.g. { gallery }...{/ gallery } for some of Image Gallery Plugins).