| Content Plugins in all Virtuemart Themes |
| Written by Thomas Kahl |
| Thursday, 22 July 2010 23:28 |
|
This is a small tip about how to use Joomla! content plugins in all Virtuemart themes. This will only work in Joomla 1.5. Open a theme file in which you want to execute plugins – for example the basket_b2c.html.php. <?php
... comment
ob_start();
?>
<table width="100%">
... theme code for the basket ...
</table>
<?php
$output=ob_get_contents();
ob_end_clean();
echo JHTML::_('content.prepare',$output);
?>
What we are doing here is to store all the output of the theme into the $output variable using ob_get_contents() within the ob_start() and ob_end_clean() block. After that, we use the Joomla! function to run all “onPrepareContent” plugins with the buffered $output and echo this in the theme. In this example we have added a plugin placeholder for the Snippets plugin “”. This will be replaced with the data the plugin returns. Another example: you could for example replace the Virtuemart image tags with the RokBox-plugin: echo "{rokbox album=|Product| thumbcount=|3|}images/stories/products/$product_id/*{/rokbox}"; In this example the RokBox plugin would create max. three thumbnails of the images stored in the given path. In the path we have included the product-id variable. This way it is very easy to manage product images just by uploading them to a given folder. This is another way to avoid a lot of hacks in Virtuemart. you can use this in (as far as i know) every theme. With this trick, you can write plugins that can dynamically replace data or extend the features of the themes. You should keep in mind that output buffering and the use of plugins may have impact on your server load. So - always think about where you use this trick. If you use it on the browse page and you display 50 products, the plugins are executed 50 times!
Set as favorite
Bookmark
Email This
Trackback(0)
Comments (2)
Write comment
|
VM-Expert.com is part of the B01 Consulting Network. Since 2003 we build shops and websites with Joomla and Virtuemart. We are specialised in developing custom Joomla and Virtuemart Extensions.