Joomla VirtueMart related products lay out
VirtueMart is a store component of Joomla CMS. It allows us to sell and comercialize any kind of products through Internet. VirtueMart allows to show detailled information about our products and other products related to it. At DiceLock Security we found that the default lay out of these related products was making our viewers to scroll horizontally …
| Applies to: Joomla 1.5 VirtueMart 1.1.3 |
These customizations are provided “AS IS” without warranty of any kind and DiceLock Security disclaims all warranties, EITHER EXPRESS OR IMPLIED INCLUDING THOSE OF MERCHANTABILITY, NONINFRINGEMENT OF THIRD-PARTY INTELLECTUAL PROPERTY, OR FITNESS FOR A PARTICULAR PURPOSE.
Upgrading or reinstalling the customized source code (package, plugin, component, …) may remove the customizations performed. |
At DiceLock Security store for each product we show viewers other products that are related to it. We have found that when there are some related products, VirtueMart shows those related products horizontally and that the veiwer must scroll hotizontally to see the web site in its full width.
Horizontally scroll in our old VirtueMart store:
We wanted that viewers would be able to see the web site in its full width and all related products with better lay out.
Looking at VirtueMart component structure we found that related products were handled by the PHP file ROOT\components\com_virtuemart\themes\default\templates\common\relatedProducts.tpl.php.
The file looked like:
<?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); ?> <hr/> <h3><?php echo $VM_LANG->_('PHPSHOP_RELATED_PRODUCTS_HEADING') ?></h3> <table width="100%" align="center"> <tr> <?php while( $products->next_record() ) { ?> <td valign="top"> <?php echo $ps_product->product_snapshot( $products->f('product_sku') ) ?> </td> <?php } ?> </tr> </table>
Where it can be seen that related products are shown within a “table”, with “one row” and “one column” for each related product.
What we have done is to change this lay out, we have removed the table and we have changed it by a “div” and we have put each related product within each own “div”. So, now file ROOT\components\com_virtuemart\themes\default\templates\common\relatedProducts.tpl.php looks like:
<?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); ?> <hr/> <h3><?php echo $VM_LANG->_('PHPSHOP_RELATED_PRODUCTS_HEADING') ?></h3> <div width="100%"> <?php while( $products->next_record() ) { ?> <div style = "float: left; width: 190px;"> <?php echo $ps_product->product_snapshot( $products->f('product_sku') ) ?> </div> <?php } ?> </div>
Now related products does not make viewers to horizontally scroll because related products looks like:
And if the viewer reduces browser’s width related products get this lay out automatically:
We prefer to show them in this way !.




































[...] Continued here: Joomla VirtueMart related products lay out – Joomla, Web Tools … [...]