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
  #31  
Old 02-18-2007, 04:37 PM
 
Sisom Sisom is offline
 

eXpert
  
Join Date: Sep 2006
Posts: 310
 

Default Re: 3 column layout with thumbnail for Related Products

ps I'd love to know how to add the "Add to cart" button to this to make it work. I've had a brief go but I can't get it work by substituting in "$product_links[cat_num].product" in:
{include file="buttons/buy_now.tpl" style="button" href="javascript: document.orderform_`$product.productid`_`$product. add_date`.submit();"}
which I took from product_box.tpl.
__________________
X-Cart Gold Version 4.3.2
Reply With Quote
  #32  
Old 04-11-2007, 05:38 AM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default 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 removed - see http://forum.x-cart.com/newreply.php?do=newreply&p=149203

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%).

How can I limit the number of items shown? For instance, lets say I want a maximum of 3 items shown, but I have 6 related products, some of which may be out of stock at times and I don't want listed then, but I want them listed instead of other items on the list if they are in stock. Is there a way to only have it "loop" a certain number of times, and how would I go about doing that? Thanks.
__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote
  #33  
Old 05-28-2007, 06:41 AM
  HWT's Avatar 
HWT HWT is offline
 

eXpert
  
Join Date: Jan 2005
Location: Massachusetts, USA
Posts: 392
 

Default Re: 3 column layout with thumbnail for Related Products

Quote:
Originally Posted by JWait
How can I limit the number of items shown? For instance, lets say I want a maximum of 3 items shown, but I have 6 related products, . . .

I know this is kind of late, but I just ran across this thread and figured if this didn't help you, it might help others.

{section} requires a name= and a loop=

There are a few more attributes that can be used though. The one you are looking for is max=

Example:

Code:
{section name=cat_num loop=$product_links max=3}

This will stop the loop at 3 instances returned.

More reading about {section}
__________________
x-cart 4.0.13 and 4.1.7 and 4.1.10
Reply With Quote
  #34  
Old 05-29-2007, 05:09 AM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default Re: 3 column layout with thumbnail for Related Products

Thanks! It took a little experimentation but I found it works fine if you put the "{section name=cat_num loop=$product_links max=3}" in the second loop.
__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote
  #35  
Old 07-18-2007, 12:59 PM
 
keystone keystone is offline
 

X-Adept
  
Join Date: Jul 2006
Location: USA
Posts: 787
 

Default Re: 3 column layout with thumbnail for Related Products

I used Sisoms code in my related_products.tpl but instead of a price I get a $ symbol under each thumbnail. How do I get a price to show up. I'm using 4.1.8 Thanks

P.S. Anyone get the buy now button?
__________________
www.uscandleco.com - X-Cart Version 4.7.11 Gold Plus php7.3
mods:
reCaptcha
running on UNIX

www.keystonecandle.com X-Cart Gold Plus - Version 4.7.11 php7.2
mods:
reCaptcha
cdseo pro
running on UNIX
Reply With Quote
  #36  
Old 07-18-2007, 01:08 PM
 
Sisom Sisom is offline
 

eXpert
  
Join Date: Sep 2006
Posts: 310
 

Default Re: 3 column layout with thumbnail for Related Products

Hi Keystone, I don't know if my code will work in 4.1.8 (I have 4.1.0) but here's what I'm using: some of it won't apply (the divs) because I'm using some CSS to create round cornered boxes for the background, but the rest of the code gives me the product thumbnail, the product title, and the price in pounds.

Here it is, just take what you want!

{* $Id: related_products.tpl,v 1.15 2005/12/07 14:07:32 max 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="0" width="100%">
<tr>
{/if}
{if $smarty.section.cat_num.index is div by 3}
</tr><tr>
{/if}

<td align="center">

<div class="relatedsidebox">
<div class="relatedboxhead"><p>

&nbsp;

</p></div>
<div class="relatedboxbody">

<a style="text-decoration: none;" 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 type="T"}</a>
<br>

<a style="color: #FFFFFF" href="product.php?productid={ $product_links[cat_num].productid }"{if $config.Modules.upselling_new_window eq 'Y'} target="_blank"{/if}>
<b>{ $product_links[cat_num].product}</b>
</a>
<br>

<font class="ProductPriceRelated">{include file="currency.tpl" value=$product_links[cat_num].taxed_price}</font>
{if $product.taxes}<font class="ProductPriceVatRelated">
{include file="customer/main/taxed_price.tpl"
taxes=$product.taxes}</font>
{/if}
</div>
</div>

</td>

{ if %cat_num.last% }
</tr></table>
{/if}
{/section}
{/capture}
{include file="dialog.tpl" title="Related products" content=$smarty.capture.dialog extra="width=100%"}
{/if}


I'm afraid I don't know how to put the Buy Now button in there, but personally I don't think it's necessary, as there is only a thumbnail and title, most customers are going to want to see the full product page before using Buy Now. (Well, I would at least!)
__________________
X-Cart Gold Version 4.3.2
Reply With Quote
  #37  
Old 07-18-2007, 01:19 PM
 
keystone keystone is offline
 

X-Adept
  
Join Date: Jul 2006
Location: USA
Posts: 787
 

Default Re: 3 column layout with thumbnail for Related Products

Good point on the buy now button. I have your code in there without the div's. I have my currency set to dollars as I am in the U.S. I still am not sure why it isn't pulling the price in and only the currency symbol. Any ideas, I'm pretty new to smarty and php. I can find my way around ok and basically know what things mean but I'm not sure what I can and cannot change yet. Which part of

<font class="ProductPrice">{include file="currency.tpl" value=$product_links[cat_num].taxed_price}</font>
{if $product.taxes}<font class="ProductPriceVat">
{include file="customer/main/taxed_price.tpl"
taxes=$product.taxes}</font>

actually pulls in the price value?
__________________
www.uscandleco.com - X-Cart Version 4.7.11 Gold Plus php7.3
mods:
reCaptcha
running on UNIX

www.keystonecandle.com X-Cart Gold Plus - Version 4.7.11 php7.2
mods:
reCaptcha
cdseo pro
running on UNIX
Reply With Quote
  #38  
Old 07-18-2007, 04:12 PM
 
Sisom Sisom is offline
 

eXpert
  
Join Date: Sep 2006
Posts: 310
 

Default Re: 3 column layout with thumbnail for Related Products

I think the part that actually pulls the price is this bit:

{if $product.taxes}<font class="ProductPriceVat">
{include file="customer/main/taxed_price.tpl"
taxes=$product.taxes}</font>


It's the taxed_price.tpl file, which is this little gem of architecture:


{* $Id: taxed_price.tpl,v 1.10 2005/11/17 06:55:38 max Exp $ *}
{if $taxes}
{foreach key=tax_name item=tax from=$taxes}
{if $tax.tax_value gt 0 or $tax.tax_value eq ""}
{if $tax.display_including_tax eq "Y"}
{if $display_info eq ""}{assign var="display_info" value=$tax.display_info}{/if}
{$lng.lbl_including_tax|substitute:"tax":$tax.tax_ display_name}{if $display_info eq "V" or ($display_info eq "A" and $tax.rate_type eq "$")} {if $is_subtax ne 'Y'}<span id="tax_{$tax.taxid}">{/if}<b>{include file="currency.tpl" value=$tax.tax_value}</b>{if $is_subtax ne 'Y'}</span>{/if}{elseif $display_info eq "R"} {if $tax.rate_type eq "$"}{include file="currency.tpl" value=$tax.rate_value}{else}{$tax.rate_value|forma tprice}%{/if}{elseif $display_info eq "A"} {if $tax.rate_type eq "%"}{$tax.rate_value|formatprice}% ({if $is_subtax ne 'Y'}<span id="tax_{$tax.taxid}">{/if}{include file="currency.tpl" value=$tax.tax_value}{if $is_subtax ne 'Y'}</span>{/if}){/if}{/if}
{* <br /> *}
{/if}
{/if}
{/foreach}
{/if}


It's not as bad as it looks though, basically it's lots of {if} tags, which then decide what to display, depending on whether you've selected to display prices including tax, etc.

I would comment out the first part (not in the taxed_price.tpl file, in the related_products.tpl file)

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

and leave this part (below), and see what you get.


{if $product.taxes}<font class="ProductPriceVat">
{include file="customer/main/taxed_price.tpl"
taxes=$product.taxes}</font>

Then do this:

{if $product.taxes}<font class="ProductPriceVat">TEST TEST TEST
{include file="customer/main/taxed_price.tpl"
taxes=$product.taxes}</font>

to see if the words "TEST TEST TEST" display. If they do, you know that the rest of the code is creating (or trying to create!) the text after the TEST words.

That's how I find out lots of things when editing the appearance of my cart - very often I'm not sure which piece of code is producing what, so I just bung in "TEST TEST TEST" somewhere in the template I'm editing, and see where it turns up.

So basically just feel free to comment out anything you want using {* *}, then you can see what code is doing what, without any risk of mucking the template up. You just delete the {* *} comment tags when you want to bring that piece of code back into action.

Let me know how you get on.
__________________
X-Cart Gold Version 4.3.2
Reply With Quote
  #39  
Old 07-18-2007, 07:07 PM
 
keystone keystone is offline
 

X-Adept
  
Join Date: Jul 2006
Location: USA
Posts: 787
 

Default Re: 3 column layout with thumbnail for Related Products

I did what you said and the TEST check did not show up at all so I think the {if $product.taxes} statement is the issue. Not sure what to do from here.

Here is the code I have now:

{* $Id: related_products.tpl,v 1.15.2.1 2007/05/02 06:05:39 max 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="0" width="100%">
{/if}

{if $smarty.section.cat_num.index is div by 3}
</tr><tr>
<tr>
<td><img src="{$ImagesDir}/spacer.gif"></td>
</tr>
<tr valign="top">
{/if}

<td width="33%" align="center">
<a style="text-decoration: none;" 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}</a>
<br>

<a href="product.php?productid={ $product_links[cat_num].productid }"{if $config.Modules.upselling_new_window eq 'Y'} target="_blank"{/if}>
<b>{ $product_links[cat_num].product}</b>
</a>
<br>


{* <font class="ProductPrice">{include file="currency.tpl" value=$product_links[cat_num].taxed_price}</font> *}
{if $product.taxes}
{include file="customer/main/taxed_price.tpl"
taxes=$product.taxes}
{/if}


</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}
__________________
www.uscandleco.com - X-Cart Version 4.7.11 Gold Plus php7.3
mods:
reCaptcha
running on UNIX

www.keystonecandle.com X-Cart Gold Plus - Version 4.7.11 php7.2
mods:
reCaptcha
cdseo pro
running on UNIX
Reply With Quote
  #40  
Old 07-19-2007, 12:31 AM
 
Sisom Sisom is offline
 

eXpert
  
Join Date: Sep 2006
Posts: 310
 

Default Re: 3 column layout with thumbnail for Related Products

Well, from that we can deduce that the second part isn't producing anything at all on screen, so it must be the first part which produces the dollar sign:

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

The value of the price comes from
$product_links[cat_num].taxed_price
and this is fed into currency.tpl, which produces the dollar sign (presumably).

I'm not too sure how exactly $product_links[cat_num].taxed_price pulls the product price through, but somebody else here is sure to have much more experience than I with this - can anybody else help?
__________________
X-Cart Gold Version 4.3.2
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 08:12 AM.

   

 
X-Cart forums © 2001-2020