Ulti Clocks content

Customise the VirtueMart 1.1 Related Products display

JOOMLABOTTOM sand How to change the default layout of VirtueMart 1.1 Related Products display.
products, product, related, file, change, number, virtuemart, relitem, snapshot, table, sku, default, joomla, display, layout, set, text, record, changes, editor, php, rounded, corners, replace, divs, open, limit, components, root, row, increase, shown, simply, cell, class, add, necessary, adjust, css, suit

Home Joomla - VirtueMart Joomla & VM How To's Customise the VirtueMart 1.1 Related Products display

Sam

18

Avr

Customise the VirtueMart 1.1 Related Products display
  • Joomla 1.5 + 1.0
  • VirtueMart 1.1

The default layout for the VirtueMart 1.1 Related Products display is a maximum of 4 products displayed in a horizontal row.

It's quite easy to change this and also to display rounded corners i.e <div><div><div><div> layout but you need to change the core files.

The default layout of the Related Products is quite "clonky".
VirtueMart standard related products display
Open file joomla_root/components/com_virtuemart/themes/default/templates/common/relatedProducts.tpl.php in any text editor.
In this case we will make the display fold at 3 products, if you want more or less just change the ($relItem == 3) parameter. The original file is as so -
 
<?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> 
 
The changes we need to make are to count the number of products and insert a new table row when we reach our required target number.
The relevant changes are within the table -
 
<table width="100%" align="center">
  <tr>
  <?php $relItemNo = 0; ?>
          <?php 
             while( $products->next_record() ) { 
        if ($relItem == 3) {
        echo "</tr>\n<tr>";
        $relItem = 0;
      }
         ?>  
     <td valign="top">
        <?php echo $ps_product->product_snapshot( $products->f('product_sku') ) ?>
     </td>
  <?php $relItem++;
      }
  ?>
       </tr>
</table>
 
If as well we want to surround the individual products in divs e.g. for a rounded corners border etc then we do this in this file as well. Simply add a class and the necessary divs to the table cell, you will have to adjust your css to suit -
 
     <td valign="top">
        <div class="related">
           <div class="module" style="width:210px;height:160px;">
              <div style="width:210px;height:160px;"><div><div></br>
           <?php echo $ps_product->product_snapshot( $products->f('product_sku') ) ?>
          </div></div></div>
            </div>
         </div>
</div>
     </td>
 
To increase the number of related products shown we need tp change another file.
Open file joomla_root/administrator/components/com_virtuemart/html/shop.product_details.php in any text editor and go to line 85.
Change the number of returned results in the query -
 
$q .= "AND FIND_IN_SET(#__{vm}_product.product_id, REPLACE(related_products, '|', ',' )) LIMIT 0, 4";
 
to for example 6
 
$q .= "AND FIND_IN_SET(#__{vm}_product.product_id, REPLACE(related_products, '|', ',' )) LIMIT 0, 6";
 
Looks better!
VirtueMart adjusted related products display


Add this page to your favorite Social Bookmarking websites
Digg! Reddit! Del.icio.us! Mixx! Free and Open Source Software News Google! Live! Facebook! Slashdot! Technorati! StumbleUpon! Spurl! Newsvine! Furl! Fark! Yahoo! Netvouz! Mister-Wong! RawSugar! Ma.gnolia! Squidoo! DZone! Swik!
LAST_UPDATED2
 

Add your comment

BoldItalicUnderlineStrikethroughSubscriptSuperscriptEmailImageHyperlinkOrdered listUnordered listQuoteCodeHyperlink to the Article by its id
Very HappySmileWinkSadSurprisedShockedConfusedCoolLaughingMadRazzEmbarrassedCrying or Very SadEvil or Very MadTwisted EvilRolling EyesExclamationQuestionIdeaArrowNeutralMr. GreenGeekUber Geek
Your name:
  The word for verification.
Lowercase letters only with no spaces.

The word for verification.<br/>Lowercase letters only with no spaces.
Word verification:

Titre:
Comment:
Comments (20)
Related Product Short Description
20 Vendredi, 02 Septembre 2011 11:01
Dusan
Can anynone help me how to display short description in related products?
Tnx
works
19 Vendredi, 05 Août 2011 07:48
Peter
Works like a charm. Got it up and running in 20 minutes. Thanks!!
i van not do this
18 Mercredi, 25 Mai 2011 12:07
mal2moh
hi
i can not do this
all code on above inserted and can nod see any things
Add to cart
17 Samedi, 25 Septembre 2010 02:14
Risal
Hey Dear!! How do you remove "add to cart" butom from the related product?
@Chris
16 Mardi, 25 Mai 2010 10:32
GJC admin
Yes, the template file is just that, a template so you can have it tableless if you want.
Just copy the existing, rename the old one so you have something to go back to if it all falls in a heap, and experiment with the layout...
Can I replace that table?
15 Mardi, 25 Mai 2010 09:52
Chris
Hi
This article is great and works well as it lead me to the right files to edit... However I would like my related products to float left and butt up to each other if there are less than the '4' I want displayed... As they are contained within a table I can't find a way to apply a float.. Any Ideas?
Can I just replace the 'table' in root/components/com_virtuemart/themes/default/templates/common/relatedProducts.tpl.php with CSS controlled Divs?
help ?
14 Lundi, 12 Avril 2010 21:12
Hey guys, could someone very kind help me with the css ? And if I would like to modify the home page of virtuemart which file I should modify ? Thank You in advace. P.
thanks so much
13 Mardi, 23 Mars 2010 21:31
miki
It works , thank you ...really

I just made a few styling modifications but it was perfect !!! Smile
Please help
12 Lundi, 22 Mars 2010 21:07
John
Can you show me your CSS for this?
need help
11 Mardi, 23 Février 2010 08:47
Guest
Can't get it working, maybe someone can share modified relatedProducts.tpl file? Thanx
@Steff
10 Mercredi, 09 Septembre 2009 14:05
GJC (admin)
Email me thru the contact page with more details..
Related products disappear
9 Mercredi, 09 Septembre 2009 13:48
Steff
It is not working for me, the related products disappear while using this code.
Working!!
8 Dimanche, 09 Août 2009 22:51
Dirk
I get it working. Just make a little mistake somewhere...

See:
http://www.dima-sports.nl/Honkbal-/-Softbal/Ballen/Champro-Official-League-Ball.html

Thanks!
Dirk
Weird...
7 Dimanche, 09 Août 2009 21:55
Dirk
Hi,
Did exactly the things you described.
Works nicely... but.
Image (or productname)is not clickable anymore. The link to the flypage is gone.
Did i do something wrong?
css styling
6 Jeudi, 06 Août 2009 13:39
@Maykel
If you need help you can contact me through the contact page...
cSS to suit
5 Jeudi, 06 Août 2009 11:44
Maykel Leijsten
Thanks for trying to help me.

My Englisch is not so good to understand than sentence. I know css but where and wich css files do i have to change?

see my sit http://www3.quickproducts.nl
@Maykel
4 Jeudi, 06 Août 2009 10:08
GJC (admin)
If as well we want to surround the individual products in divs e.g. for a rounded corners border etc then we do this in this file as well. Simply add a class and the necessary divs to the table cell, - you will have to adjust your css to suit
Tried but nothing changed
3 Jeudi, 06 Août 2009 09:34
Maykel Leijsten
Hi I also tried the modification in virtuemart 1.1.3 but nothing happens. Is there something we do wrong?
@Radoslaw
2 Samedi, 25 Juillet 2009 06:36
GJC (admin)
With all your feedback and information I've finally worked out that it's not working because the wind is coming from the east.
Try turning the PC around 180 degrees, should work then...

Wearing a hat while coding should make it simpler next time as well...
About
1 Vendredi, 24 Juillet 2009 21:20
Radoslaw
It`s not working. I changed the code ,but nothing happend.

Our Recommended Reading

For those interested in extending their knowledge of Joomla! & VirtueMart, Packt Publishing has an excellent range of help & how to books.
Listed below are some I can recommend.
Simply click on the images to be taken directly to their web shop.


Joomla! Social Networking with JomSocial
Joomla! Social Networking
with JomSocial

by Kwasi Boateng & Beatrice A. Boateng.
Joomla! 1.5 Multimedia
Joomla! 1.5 Multimedia
by Allan Walker.


Building job sites with Joomla!
Building job sites with Joomla!
by Santonu Kumar Dhar.

Joomla! Template Design: Create your own professional-quality templates with this fast, friendly guide
Joomla! Template Design: 2nd Edition
Create your own professional-quality
templates with this fast, friendly guide
by Tessa Blakeley Silver.
Magento: Beginner's Guide
Magento: Beginner's Guide by William Rice
is a must for anyone trying the
open-source e-Commerce solution.

Read the review

object-oriented-javascript-applications-libraries
Object-Oriented JavaScript by
Stoyan Stefanov gives you a very
comprehensive grounding in
the latest Javascript techniques.

Read the review
Joomla! Web Security
Joomla! Web Security
by Tom Canavan.

Joomla 1.5 Top Extensions Cookbook
Joomla 1.5 Top Extensions Cookbook by
Suhreed Sarkar is an ideal and concise round up of the extensions available for the Joomla! system.

Read the review

Latest Articles

Paypal Donation

If you use this module on your site please donate a small amount.
Any donation amount appreciated.

VM Live Product Search

Recommended Reading

For those interested in extending there knowledge of Joomla! & VirtueMart Packt Publishing has an excellent range of help & how to books.
Listed below are some I can recommend.
Simply click on the images to be taken directly to their web shop.

Mastering Joomla! 1.5 Extension and Framework Development
Mastering Joomla! 1.5 Extension and
Framework Development : 2nd Edition

by James Kennard.
Read the review

Building job sites with Joomla!
Building job sites with Joomla!
by Santonu Kumar Dhar.
Learning Joomla! 1.5 Extension Development Learning Joomla! 1.5 Extension Development
by Joseph L. LeBlanc.
Read the review
Joomla! E-Commerce with VirtueMart
Joomla! E-Commerce with VirtueMart
by Suhreed Sarkar.

Read the review
Joomla! 1.5 Site Blueprints Joomla! 1.5 Site Blueprints
by Timi Ogunjobi.

Joomla! 1.5 JavaScript jQuery Joomla! 1.5 JavaScript jQuery
by Jose Argudo Blanco.
Read the review
Joomla! Social Networking with JomSocial Joomla! Social Networking with JomSocial
by Kwasi Boateng & Beatrice A. Boateng.

Joomla! 1.5 Multimedia Joomla! 1.5 Multimedia
by Allan Walker.

Joomla! Web Security Joomla! Web Security
by Tom Canavan.

Mastering Joomla! 1.5 Extension and Framework Development Mastering Joomla! 1.5 Extension and Framework Development : 2nd Edition
by James Kennard.

Joomla! Template Design: Create your own professional-quality templates with this fast, friendly guide Joomla! Template Design: Edition 2 - Create your own professional-quality templates with this fast, friendly guide
by Tessa Blakeley Silver.

Magento: Beginner's Guide
Magento: Beginner's Guide by William Rice
is a must for anyone trying the
open-source e-Commerce solution.

Read the review

JOOMLABOTTOM



Customise the VirtueMart 1.1 Related Products display



How to change the default layout of VirtueMart 1.1 Related Products display.


products, product, related, file, change, number, virtuemart, relitem, snapshot, table, sku, default, joomla, display, layout, set, text, record, changes, editor, php, rounded, corners, replace, divs, open, limit, components, root, row, increase, shown, simply, cell, class, add, necessary, adjust, css, suit