Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

3 column layout with thumbnail for Related Products

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #41  
Old 07-20-2007, 10:16 PM
 
brianb777 brianb777 is offline
 

Member
  
Join Date: Jul 2007
Posts: 11
 

Default Re: 3 column layout with thumbnail for Related Products

thanks!
__________________
http://mortersupplements.com
Currently running X-Cart Gold 4.1.8
Reply With Quote
  #42  
Old 07-24-2007, 04:36 AM
 
john12345 john12345 is offline
 

Member
  
Join Date: Sep 2005
Location: Melbourne, Australia
Posts: 22
 

Default Re: 3 column layout with thumbnail for Related Products

Does anyone know how to make this snippet XHTML compliant? The code works fine until you have more than one row of related products.

Currently, the code ends a table row only when we reach the last row of related products

Code:
{ if %cat_num.last% } </tr></table><br /> {/if}

I need the code to add the appropriate </tr> tag before starting a new <tr>. Any ideas anyone?

I tried pinching the appropriate code from subcategories.tpl (which correctly adds </tr> after each row), but my limited coding skills just left me confused
__________________
xcart v4.1.2 [unix]
Reply With Quote
  #43  
Old 07-24-2007, 08:44 AM
 
Sisom Sisom is offline
 

eXpert
  
Join Date: Sep 2006
Posts: 310
 

Default Re: 3 column layout with thumbnail for Related Products

I'm a bit lost about what you are trying to do exactly. The code I have allows a maximum of three products per row, then creates a new row.

How about this?

{ if %cat_num.3 }
</tr>
{/if}


{ if %cat_num.last% }
</tr></table>
{/if}
{/section}
{/capture}

I'm guessing at the "3" in { if %cat_num.3 } as I don't know much about Smarty either, but presumably it would then insert a </tr> after the third item?

If your code doesn't add a </tr> after each row, then how does it create a second row? Isn't that impossible without the </tr> tag being there somehow?
__________________
X-Cart Gold Version 4.3.2
Reply With Quote
  #44  
Old 07-24-2007, 09:49 AM
 
john12345 john12345 is offline
 

Member
  
Join Date: Sep 2005
Location: Melbourne, Australia
Posts: 22
 

Default Re: 3 column layout with thumbnail for Related Products

Thanks Sisom for your suggestion but this won't work

Code:
{ if %cat_num.3 } </tr> {/if}

I had another little play around and ended up using the code below. I don't know how or why it works but it does and so now i've got XHTML validated product pages. This code works on the assumption that you've got three thumnails across and no more than 12 related items. If you wanted to have more than 12 I guess you could just add an extra $smarty.section.cat_num.index eq 11.

Code:
</td> {if $smarty.section.cat_num.index eq 2 || $smarty.section.cat_num.index eq 5 || $smarty.section.cat_num.index eq 8 || %cat_num.last% } </tr> {/if} {/section} </table> {/capture}
I just love it when you've got absolutely no idea how or why something works but it does anyway.

If you want to have a look at it in action see here: http://www.ausgardener.com.au/Diamond-Night-pr-762.html
__________________
xcart v4.1.2 [unix]
Reply With Quote
  #45  
Old 07-24-2007, 10:58 AM
 
Sisom Sisom is offline
 

eXpert
  
Join Date: Sep 2006
Posts: 310
 

Default Re: 3 column layout with thumbnail for Related Products

Great stuff! You certainly know more about Smarty than I do! Loved the look of your site too - very clear and professional.
__________________
X-Cart Gold Version 4.3.2
Reply With Quote
  #46  
Old 08-19-2007, 12:03 PM
 
MoonDog MoonDog is offline
 

Advanced Member
  
Join Date: Aug 2007
Posts: 93
 

Default Re: 3 column layout with thumbnail for Related Products

keystone,

If you want the price to show up in sisoms code from post #36, then you need to change this line of code:

Code:
<font class="ProductPriceRelated">{include file="currency.tpl" value=$product_links[cat_num].taxed_price}</font>

to this:

Code:
<font class="ProductPriceRelated">{include file="currency.tpl" value=$product_links[cat_num].price}</font>

I have v4.1.8 and it seems to be working O.K. for me.

- MoonDog -
__________________
X-CART Gold v4.1.8
Reply With Quote
  #47  
Old 09-22-2007, 06:39 AM
  vahidnia's Avatar 
vahidnia vahidnia is offline
 

Advanced Member
  
Join Date: Aug 2007
Location: USA
Posts: 48
 

Question Re: 3 column layout with thumbnail for Related Products

Quote:
Originally Posted by balinor
For anyone who wants this to work for 4.0.18, here's the code to use:

Code:
{if $product_links ne ""} {capture name=dialog} {assign var="tmp" value="0"} {section name=cat_num loop=$product_links} {if $product_links[cat_num].productid}{assign var="tmp" value="1"}{/if} {/section} {section name=cat_num loop=$product_links} { if %cat_num.first% } <table border="0" cellspacing="5" width="100%"> {/if} {if $smarty.section.cat_num.index is div by 3} </tr><tr valign="top"> {/if} <TD width="33%" align="center"> <A href="product.php?productid={ $product_links[cat_num].productid }"{if $config.Modules.upselling_new_window eq 'Y'} target="_blank"{/if}> {include file="product_thumbnail.tpl" productid=$product_links[cat_num].productid image_x=$config.Appearance.thumbnail_width product=$product_links[cat_num].product tmbn_url=$product_links[cat_num].tmbn_url}<br> { $product_links[cat_num].product} </A> </TD> { if %cat_num.last% } </tr></table><br> {/if} {/section} {/capture} {include file="dialog.tpl" title="You may also like..." content=$smarty.capture.dialog extra="width=100%"} {/if}

It is set for 3 columns, but you can change that by changing the number 3 to whatever you want, and also change the percentage for the width of the table cell (currently set to 33%).

Balinor,
No one seems to have posted a clean version of this mod for Version 4.1.8
and i cant get this to work on mine no matter how many times I modify the codes (It still shows the same unglorious text). here is my related_products.tpl code:
Code:
{* $Id: related_products.tpl,v 1.15.2.1 2007/05/02 06:05:39 max Exp $ *} {if $product_links ne ""} {capture name=dialog} <table cellspacing="5"> {section name=cat_num loop=$product_links} <tr class="ItemsList"> <td width="1%">#{$product_links[cat_num].productid}</td> <td width="99%"><a href="product.php?productid={$product_links[cat_num].productid}"{if $config.Upselling_Products.upselling_new_window eq 'Y'} target="_blank"{/if} class="ItemsList">{$product_links[cat_num].product|amp}</a></td> </tr> {/section} </table> {/capture} {include file="dialog.tpl" title=$lng.lbl_related_products content=$smarty.capture.dialog extra='width="100%"'} {/if}
Can you please have a look at this and tell me what part do I have to modify to make it compatible with 4.1.8. (Or let me know if I have to make any changes in any other file)
Thanks,
V
__________________
X-cart gold 4.4.3
Unix
Reply With Quote
  #48  
Old 09-30-2007, 10:00 PM
 
MoonDog MoonDog is offline
 

Advanced Member
  
Join Date: Aug 2007
Posts: 93
 

Default Re: 3 column layout with thumbnail for Related Products

vahidnia,

Just copy sisom's code from post #36 and save it as related_products.tpl

Make sure you change one line of code as noted on my previous post above.

This change is to display the cost of the product underneath the thumbnail.

I have v4.1.8 and had no problems using the above mentioned procedure and it's actually working pretty nice.

- MoonDog -
__________________
X-CART Gold v4.1.8
Reply With Quote
  #49  
Old 10-01-2007, 09:52 PM
  vahidnia's Avatar 
vahidnia vahidnia is offline
 

Advanced Member
  
Join Date: Aug 2007
Location: USA
Posts: 48
 

Default Re: 3 column layout with thumbnail for Related Products

MoonDog,
Thank you very much for your help. I kinda mixed "related products" and "recommended products" in the begining. I actually needed the 3 column layout for recommended products which i got from another post.
Thanks you again,
V
__________________
X-cart gold 4.4.3
Unix
Reply With Quote
  #50  
Old 10-11-2007, 05:22 PM
 
eddy eddy is offline
 

Senior Member
  
Join Date: Jan 2007
Location: California
Posts: 152
 

Default Re: 3 column layout with thumbnail for Related Products

Great Mod working in 4.1.8
Question after upgrade should I restore to default than add the mod or just leave it as is.
__________________
www.goldnwax.com
v5.4.30
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:59 AM.

   

 
X-Cart forums © 2001-2020