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

Related Products.tpl - thumbnail alignment problem

 
Reply
   X-Cart forums > X-Cart 4 > Changing design
 
Thread Tools Search this Thread
  #1  
Old 04-23-2005, 03:40 PM
 
NJB NJB is offline
 

Member
  
Join Date: Mar 2005
Posts: 28
 

Default Related Products.tpl - thumbnail alignment problem

Hi,

I've edited related_products.tpl so that they display as thumbnail images, with 4 products across the page.

The page views fine when I have 4 products (the maximum) but when I only add 2 products to up-sell there is a problem with alignment. eg, if you imagine 4 thumbnail boxes across the page numbered 1-4 from left to right, then with 2 products selected the products show only in position 2 and 4. It just looks a little odd to have the products sitting centred and to the far right of the page. Ideally, I'd like them both left aligned in box positions no. 1 & 2.

I've posted my code below, and would really appreciate if someone can please point out where I'm going wrong.

Thanks,
Tracy

Code:
{* $Id: related_products.tpl,v 1.7.6.1 2004/12/06 svowl Exp $ *} {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 4} </tr> <tr align="left" valign="top"> {/if} <td align="center" valign="top"> <td width="90" align="center"> {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} <a href="product.php?productid={ $product_links[cat_num].productid }"{if $config.Modules.upselling_new_window eq 'Y'} target="_blank"{/if}> <span class="ProductTitle">{ $product_links[cat_num].product|escape}</span> </a></td> { if %cat_num.last% } </tr></table> {/if} {/section} {/capture} {include file="dialog.tpl" title=$lng.lbl_related_products content=$smarty.capture.dialog extra="width=100%"} {/if}
__________________
NJB
Sydney, Australia
x-Cart Version 4.0.12
Reply With Quote
  #2  
Old 07-09-2005, 03:46 AM
 
Online Michael Online Michael is offline
 

eXpert
  
Join Date: Mar 2005
Location: Melbourne, Australia
Posts: 273
 

Default

I don't know if you have fixed your problem or not so just in case, here is my solution (better late than never). Just replace the entire contents of your related_products.tpl file with this:

Code:
{* $Id: related_products.tpl,v 1.10.6.1 2004/12/06 svowl Exp $ *} {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="2" width="100%"> {/if} {if $smarty.section.cat_num.index is div by 4} <tr valign="top"> {/if} <td width="{$product_links}%" align="center" valign="top"> {include file="product_thumbnail.tpl" productid=$product_links[cat_num].productid image_y=70 product=$product_links[cat_num].product tmbn_url=$product_links[cat_num].tmbn_url} <a href="product.php?productid={ $product_links[cat_num].productid }"{if $config.Modules.upselling_new_window eq 'Y'} target="_blank"{/if}> <font class="ProductTitle"> {$product_links[cat_num].product|escape}</font></a> <FONT class="ProductDetailsTitle">{include file="currency.tpl" value=$product_links[cat_num].price}</FONT><FONT class="MarketPrice">{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$product_links[cat_num].price}</FONT> </td> { if %cat_num.last% } </tr></table> {/if} {/section} {/capture} {include file="dialog.tpl" title=$lng.lbl_related_products content=$smarty.capture.dialog extra="width=100%"} {/if}

You will notice that the code will center all related products very nicely accross your page regardless of wether you have 1 product or 4. If you want more products then replace 4 with whatever number you wish. The mod also includes price and alternate price. Just remove it if you don't need it. Hope this helps.
__________________
X-Cart 5.3.5.4
Reply With Quote
  #3  
Old 07-09-2005, 08:13 AM
 
kirsten kirsten is offline
 

Senior Member
  
Join Date: Feb 2005
Location: Sydney, Australia
Posts: 104
 

Default

Do you know how to stop the related products opening up in a new window?

Thanx
Kirsten
__________________
Kirsten
X_Cart Gold Version 4.0.11
www.silverimports.com.au
www.diamondimports.com.au
Reply With Quote
  #4  
Old 07-09-2005, 08:15 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default

There is a setting in General Settings/Modules options for that
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #5  
Old 07-09-2005, 02:26 PM
 
kirsten kirsten is offline
 

Senior Member
  
Join Date: Feb 2005
Location: Sydney, Australia
Posts: 104
 

Default

THANX Padraic found it
Another annoying problem now solved

Do you think the above code would work for Recommended Products?

And would there be much difference in the coding?

As I want my recommends products to have the same layout

Regards
Kirsten
__________________
Kirsten
X_Cart Gold Version 4.0.11
www.silverimports.com.au
www.diamondimports.com.au
Reply With Quote
  #6  
Old 07-09-2005, 02:56 PM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default

Compare the two side by side and you'll see the differences. Both mods are posted in the Custom Mods forum.
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #7  
Old 07-22-2005, 07:26 AM
 
larrydavidow larrydavidow is offline
 

Advanced Member
  
Join Date: Feb 2005
Posts: 38
 

Default

Quote:
Originally Posted by Online Michael
I don't know if you have fixed your problem or not so just in case, here is my solution (better late than never). Just replace the entire contents of your related_products.tpl file with this:

Code:
{* $Id: related_products.tpl,v 1.10.6.1 2004/12/06 svowl Exp $ *} {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="2" width="100%"> {/if} {if $smarty.section.cat_num.index is div by 4} <tr valign="top"> {/if} <td width="{$product_links}%" align="center" valign="top"> {include file="product_thumbnail.tpl" productid=$product_links[cat_num].productid image_y=70 product=$product_links[cat_num].product tmbn_url=$product_links[cat_num].tmbn_url} <a href="product.php?productid={ $product_links[cat_num].productid }"{if $config.Modules.upselling_new_window eq 'Y'} target="_blank"{/if}> <font class="ProductTitle"> {$product_links[cat_num].product|escape}</font></a> <FONT class="ProductDetailsTitle">{include file="currency.tpl" value=$product_links[cat_num].price}</FONT><FONT class="MarketPrice">{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$product_links[cat_num].price}</FONT> </td> { if %cat_num.last% } </tr></table> {/if} {/section} {/capture} {include file="dialog.tpl" title=$lng.lbl_related_products content=$smarty.capture.dialog extra="width=100%"} {/if}

You will notice that the code will center all related products very nicely accross your page regardless of wether you have 1 product or 4. If you want more products then replace 4 with whatever number you wish. The mod also includes price and alternate price. Just remove it if you don't need it. Hope this helps.

Thanks for the Mod Michael!!! Just what I was looking for. If this forum had a star system, you'd get a few from me!!
__________________
X-Cart Gold
4.5.4
Reply With Quote
  #8  
Old 12-17-2007, 07:14 AM
 
kevin34 kevin34 is offline
 

Advanced Member
  
Join Date: Aug 2007
Posts: 41
 

Default Re: Related Products.tpl - thumbnail alignment problem

Hi Balinor,

I realise that this is an old thread, but hoped I could get some help on a small problem that I cannot fix myself (and I have tried!).
I am using the following code for my related_products.tpl:

HTML Code:
{* $Id: related_products.tpl,v 1.10.6.1 2004/12/06 svowl Exp $ *} {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="2" width="100%"> {/if} {if $smarty.section.cat_num.index is div by 4} <tr valign="top"> {/if} <td width="{$product_links}%" align="center" valign="top"> {include file="product_thumbnail.tpl" productid=$product_links[cat_num].productid image_y=70 product=$product_links[cat_num].product tmbn_url=$product_links[cat_num].tmbn_url} <a href="product.php?productid={ $product_links[cat_num].productid }"{if $config.Modules.upselling_new_window eq 'Y'} target="_blank"{/if}> <font class="ProductTitle"> {$product_links[cat_num].product|escape}</font></a> <FONT class="ProductDetailsTitle">{include file="currency.tpl" value=$product_links[cat_num].price}</FONT><FONT class="MarketPrice">{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$product_links[cat_num].price}</FONT> </td> { if %cat_num.last% } </tr></table> {/if} {/section} {/capture} {include file="dialog.tpl" title=$lng.lbl_related_products content=$smarty.capture.dialog extra="width=100%"} {/if}

This works great except that ii shows the name and price to the right of the thumbnail and I wish it that the name is centralised under the thumbnail image and the price is under the name √ could you help with this?

I have attached a gif as it it now
Many thanks
Kev
Attached Thumbnails
Click image for larger version

Name:	related products.gif
Views:	23
Size:	8.0 KB
ID:	696  
__________________
X-Cart Gold 4.3
Reply With Quote

The following user thanks kevin34 for this useful post:
eaglemobiles (05-05-2010)
  #9  
Old 06-09-2008, 08:38 AM
 
wtx wtx is offline
 

Newbie
  
Join Date: May 2008
Location: Buh
Posts: 1
 

Default Re: Related Products.tpl - thumbnail alignment problem

try put <center></center> tag to your problem
__________________
x-cart 4.1.10 php 5
Reply With Quote
  #10  
Old 06-09-2008, 10:36 AM
 
kevin34 kevin34 is offline
 

Advanced Member
  
Join Date: Aug 2007
Posts: 41
 

Default Re: Related Products.tpl - thumbnail alignment problem

Hi

many thanks for the reply - we needed to crack on and get the issue resolved so finally paid x-cart to solve the issue - thanks for the reply though

Kev

Quote:
Originally Posted by wtx
try put <center></center> tag to your problem
__________________
X-Cart Gold 4.3
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 11:00 PM.

   

 
X-Cart forums © 2001-2020