{"id":255,"date":"2010-04-01T21:33:07","date_gmt":"2010-04-01T19:33:07","guid":{"rendered":"http:\/\/kavdesign.net\/wordpress\/?p=255"},"modified":"2010-04-01T21:35:10","modified_gmt":"2010-04-01T19:35:10","slug":"customise-the-virtuemart-1-1-related-products-display","status":"publish","type":"post","link":"https:\/\/www.kavdesign.net\/blog\/coding\/customise-the-virtuemart-1-1-related-products-display\/","title":{"rendered":"Customise the VirtueMart 1.1 Related Products display"},"content":{"rendered":"<p>The default layout for the VirtueMart 1.1 Related Products display is a maximum of 4 products displayed in a horizontal row.<\/p>\n<p>It&#8217;s quite easy to change this and also to display rounded corners i.e &lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt; layout but you need to change the core files.<\/p>\n<p>The default layout of the Related Products is quite &#8220;clonky&#8221;.<\/p>\n<p><!--more-->Open file joomla_root\/components\/com_virtuemart\/themes\/default\/templates\/common\/relatedProducts.tpl.php in any text editor.<br \/>\nIn 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 &#8211;<\/p>\n<blockquote><p>&lt;?php if( !defined( &#8216;_VALID_MOS&#8217; ) &amp;&amp; !defined( &#8216;_JEXEC&#8217; ) ) die( &#8216;Direct Access to &#8216;.basename(__FILE__).&#8217; is not allowed.&#8217; ); ?&gt;<br \/>\n&lt;hr\/&gt;<br \/>\n&lt;h3&gt;&lt;?php echo $VM_LANG-&gt;_(&#8216;PHPSHOP_RELATED_PRODUCTS_HEADING&#8217;) ?&gt;&lt;\/h3&gt;<br \/>\n&lt;table width=&#8221;100%&#8221; align=&#8221;center&#8221;&gt;<br \/>\n&lt;tr&gt;<br \/>\n&lt;?php<br \/>\nwhile( $products-&gt;next_record() ) { ?&gt;<br \/>\n&lt;td valign=&#8221;top&#8221;&gt;<br \/>\n&lt;?php echo $ps_product-&gt;product_snapshot( $products-&gt;f(&#8216;product_sku&#8217;) ) ?&gt;<br \/>\n&lt;\/td&gt;<br \/>\n&lt;?php<br \/>\n}<br \/>\n?&gt;<br \/>\n&lt;\/tr&gt;<br \/>\n&lt;\/table&gt;<\/p><\/blockquote>\n<p>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.<br \/>\nThe relevant changes are within the table &#8211;<\/p>\n<blockquote><p>&lt;table width=&#8221;100%&#8221; align=&#8221;center&#8221;&gt;<br \/>\n&lt;tr&gt;<br \/>\n&lt;?php $relItemNo = 0; ?&gt;<br \/>\n&lt;?php<br \/>\nwhile( $products-&gt;next_record() ) {<br \/>\nif ($relItem == 3) {<br \/>\necho &#8220;&lt;\/tr&gt;\\n&lt;tr&gt;&#8221;;<br \/>\n$relItem = 0;<br \/>\n}<br \/>\n?&gt;<br \/>\n&lt;td valign=&#8221;top&#8221;&gt;<br \/>\n&lt;?php echo $ps_product-&gt;product_snapshot( $products-&gt;f(&#8216;product_sku&#8217;) ) ?&gt;<br \/>\n&lt;\/td&gt;<br \/>\n&lt;?php $relItem++;<br \/>\n}<br \/>\n?&gt;<br \/>\n&lt;\/tr&gt;<br \/>\n&lt;\/table&gt;<\/p><\/blockquote>\n<p>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 &#8211;<\/p>\n<blockquote><p>&lt;td valign=&#8221;top&#8221;&gt;<br \/>\n&lt;div&gt;<br \/>\n&lt;div style=&#8221;width:210px;height:160px;&#8221;&gt;<br \/>\n&lt;div style=&#8221;width:210px;height:160px;&#8221;&gt;&lt;div&gt;&lt;div&gt;&lt;\/br&gt;<br \/>\n&lt;?php echo $ps_product-&gt;product_snapshot( $products-&gt;f(&#8216;product_sku&#8217;) ) ?&gt;<br \/>\n&lt;\/div&gt;&lt;\/div&gt;&lt;\/div&gt;<br \/>\n&lt;\/div&gt;<br \/>\n&lt;\/div&gt;<br \/>\n&lt;\/div&gt;<br \/>\n&lt;\/td&gt;<\/p><\/blockquote>\n<p>To increase the number of related products shown we need tp change another file.<br \/>\nOpen file joomla_root\/administrator\/components\/com_virtuemart\/html\/shop.product_details.php in any text editor and go to line 85.<br \/>\nChange the number of returned results in the query &#8211;<\/p>\n<blockquote><p>$q .= &#8220;AND FIND_IN_SET(#__{vm}_product.product_id, REPLACE(related_products, &#8216;|&#8217;, &#8216;,&#8217; )) LIMIT 0, 4&#8221;;<\/p><\/blockquote>\n<p>to for example 6<\/p>\n<blockquote><p>$q .= &#8220;AND FIND_IN_SET(#__{vm}_product.product_id, REPLACE(related_products, &#8216;|&#8217;, &#8216;,&#8217; )) LIMIT 0, 6&#8221;;<\/p><\/blockquote>\n<p>Original article from: http:\/\/www.gjcwebdesign.com\/virtuemart-related-products-customise.html<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The default layout for the VirtueMart 1.1 Related Products display is a maximum of 4 products displayed in a horizontal row. It&#8217;s quite easy to<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/www.kavdesign.net\/blog\/coding\/customise-the-virtuemart-1-1-related-products-display\/\">Continue reading<span class=\"screen-reader-text\">Customise the VirtueMart 1.1 Related Products display<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[9],"tags":[],"class_list":["post-255","post","type-post","status-publish","format-standard","hentry","category-coding","entry"],"_links":{"self":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/comments?post=255"}],"version-history":[{"count":3,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/255\/revisions"}],"predecessor-version":[{"id":257,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/255\/revisions\/257"}],"wp:attachment":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/media?parent=255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/categories?post=255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/tags?post=255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}