X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Pictures in recommends.tpl for 3 column format (https://forum.x-cart.com/showthread.php?t=7506)

mlfnet 05-09-2004 10:21 AM

Pictures in recommends.tpl for 3 column format
 
I was looking around the forums to display pictures in the recommends.tpl and came across some code, but it had prices and was setup for 1 column. I edited it so it would display in a 3 colums with just the picture and title.


Code:

{* $Id: recommends.tpl,v 1.3 2004/03/01 16:26:00 salsabeel Exp $ *}
{if $recommends}
{capture name=recommends}

<table border=0 width=100%>
<tr>

{section name=num loop=3}
<td width=90 align=center valign=top>
{$recommends[num].product}</font>
</td>
{/section}

</tr>
</table>


{/capture}
{include file="dialog.tpl" title=$lng.lbl_recommends content=$smarty.capture.recommends extra="width=100%"}{/if}


Hope this helps some of you out. It could probably stand to be cleaned up a little. I just hacked it enough to make it do what I needed it to do.

adpboss 05-09-2004 10:25 AM

Good one, thanks!

What version is this codee for?

I'm sure a Moderator will come along and move this to Custom Mods soon.

mlfnet 05-17-2004 03:03 PM

Version 3.5.x
 
It works on mine which is 3.5.5

donavichi 05-20-2004 11:40 PM

Works on 3.5.7 too!

Thank you

GM 05-21-2004 01:26 PM

Nice one! and just in time, I was just wandering how to do this :D

donavichi 05-27-2004 09:48 AM

I have thumbnail images stored on file system not in database

Can you tell me how to adapt the code to display the images?

Many thanks,

Donavichi

xcell67 05-29-2004 05:43 PM

don,

were u able to figure out how to call it from the filesystem rather than the DB?

donavichi 05-31-2004 01:58 AM

not as yet, no.

Any ideas?

balinor 12-03-2004 01:31 PM

This mod works very nicely for the recommended products.....however I would like to adapt it for the related products/upselling links. Basically a three column layout with icons, just like this. I saw another mod that tweaked the upsell links, but added way too much info for me, and in only one column.

If anyone has happened to adapt this mod to the upsell template, please post it. Thanks! :)

ETInteractive.com 12-03-2004 02:37 PM

Just look at products.tpl or products_t.tpl

this has the smarty call for product thumbnails.

balinor 12-03-2004 03:28 PM

Ok, managed to pull the icon in, split it up into a 3 column layout and it looks great. Only problem is, if there is only one upselling link, the other two columns show the 'image not available' icon. What I suppose I need is a function to tell X-Cart to not display anything in the extra columns if there are only one or two items. A little help? :) Here's what I have for code:

Code:

{* $Id: related_products.tpl,v 1.7.6.1 2004/07/15 10:28:54 svowl Exp $ *}
{if $product_links ne ""}
{capture name=dialog}
<table border=0 cellspacing=5 align="center" width="100%">
<tr>
{section name=cat_num loop=3}
<td width=250 align=center valign=top>
{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>{/section}
</tr>
</table>
{/capture}
{include file="dialog.tpl" title=$lng.lbl_related_products content=$smarty.capture.dialog extra="width=100%"}
{/if}


GM 12-05-2004 01:46 PM

It's because you are telling it to loop 3 times...
Code:

{section name=cat_num loop=3}
(but I suppose that is how you got three columns.)

balinor 12-05-2004 02:08 PM

Yep. What I need is an {if} statement in there that tells it to not display anything if there is only 1 or 2 products. Anyone care to help me out with that? I don't know Smarty well enough yet to come up with anything.

adpboss 12-05-2004 02:12 PM

You need to count the number of results in the loop.

Look for a thread in Custom Mods by 27stars and about subcategory display. You can use a similar method to accomplish what you want to do.

or look at skin1/customer/main/productS.tpl

balinor 12-06-2004 07:09 AM

Solution here: http://forum.x-cart.com/viewtopic.php?t=14995

longhorn180 04-04-2005 10:55 AM

I really like this mod but do have one question, how would I make this mod display a 3x3 table with 9 recommended products instead of just the 3? Thanks in advance.

flamers 04-11-2005 11:07 AM

The original 3 column recommends code works fine in V4 (my version anyway), but it looks a bit clumsy as is because it squashes the item title against left hand side. It's easily fixed, here's the original code:

Code:

{* $Id: recommends.tpl,v 1.3 2004/03/01 16:26:00 salsabeel Exp $ *}
{if $recommends}
{capture name=recommends}

<table border=0 width=100%>
<tr>

{section name=num loop=3}
<td width=90 align=center valign=top>
{$recommends[num].product}</font>
</td>
{/section}

</tr>
</table>

 
{/capture}
{include file="dialog.tpl" title=$lng.lbl_recommends content=$smarty.capture.recommends extra="width=100%"}{/if}


Just modify the first part to this:

Code:

{if $recommends}
{capture name=recommends}

<table border=0 width=100%>
<tr>

{section name=num loop=3}
<td width=200 align=center valign=top>


et voila, just by changing the table width to 200 the title stretches all the way under the thumbnail.

Online Michael 04-13-2005 02:21 AM

Quote:

Originally Posted by longhorn180
I really like this mod but do have one question, how would I make this mod display a 3x3 table with 9 recommended products instead of just the 3? Thanks in advance.


Yes, this would be very nice. I have managed to squeeze in 4 columns across but would like another one or two more rows of it. Had a go at doing it myself, but with no success. The mod works great on 4.0.13 btw.

Lingerieblowout 04-26-2005 06:22 AM

Did anyone figure out the IF statement to make a loop count and if EQ then add a


So if loop = 6 and 3 are written a
would come before the 4th one.

Lingerieblowout 04-26-2005 07:30 PM

This is how I tried to do it but still make 1 row of six instead of 2 rows of 3

{* $Id: recommends.tpl,v 1.3 2004/03/01 16:26:00 salsabeel Exp $ *}
{if $recommends}
{capture name=recommends}

{assign var="col" value="0"}
{assign var="numCols" value="3"}

<table border=0 width=100%>
<tr>

{section name=num loop=6}


{if $col == $numCols}
</tr><tr>{assign var="col" value="0"}
{/if}


<td width=200 align=center valign=top>
{$recommends[num].product}</font>
</td>
{assign var="col" value="`$col+1`"}
{/section}

</tr>
</table>



{/capture}
{include file="dialog.tpl" title=$lng.lbl_recommends content=$smarty.capture.recommends extra="width=100%"}{/if}

MythNReality 05-14-2005 02:53 PM

Quote:

Originally Posted by balinor

Hugs to Balinor, that's was exactly what I was looking for \:D/

balinor 07-16-2005 08:44 AM

Just a little update on this thread. Here's the code for 4.x that breaks the display up into rows of 3, allowing as many recommended products as you want (as set in General Settings/Modules Options). Just change the thumbnail width as you would like (in pixels). You can also adjust the number of columns by changing the width of the td and the 'div by x' where x is the number of columns:

Code:

{if $recommends}
{capture name=recommends}
{section name=num loop=$recommends}
{ if %num.first% }
<table border=0 width=100%>{/if}
{ if %num.index% is div by 3}<tr>{/if}

<td width="33%" align="center" valign="top">
<a href=product.php?productid={$recommends[num].productid}&cat={$cat}&page={$navigation_page}>{include file="product_thumbnail.tpl" productid=$recommends[num].productid image_x=100 product=$recommends[num].product tmbn_url=$recommends[num].tmbn_url}

<SPAN class="ItemsList">{$recommends[num].product}</SPAN>

</td>

{ if %num.last% }</tr>
</table>{/if}
{/section}
{/capture}
{include file="dialog.tpl" title=$lng.lbl_recommends content=$smarty.capture.recommends extra="width=100%"}
{/if}


Lingerieblowout 07-16-2005 10:37 AM

Thanks balinor....

His last post also works in XC 3.4.6

Michael

balinor 07-16-2005 10:41 AM

Yea, code hasn't changed much in these templates since way back when :)

Bling 07-27-2005 06:11 PM

Hey there Balinor...I just tried this with 13 and it doesnt seem to do anything. I have hooters url app installed and I noticed he has some code in there. Have you tried this app with any of your customers with his url app?

This is exactly what the doctor ordered...pictures with the recomended products. :D

Thanks,
Bling

Lionel 02-25-2006 02:12 AM

Balinor, you code works perfect, thanks. However, the thumb_url value is not passed

Code:

tmbn_url=$recommends[num].tmbn_url


Please how can I build that array in recommends.php?

Thanks.

Lionel 02-25-2006 05:52 AM

I figured it out and am posting the soution in case someone else wants it.
(that's to use with TelaFirma's mod)

in recommends.php

after
Code:

if(!empty($products_id)) {
foreach($products_id as $p) {
$query_ids[] = $p['productid'];


simply put
Code:

$rec_thumb_url[]=func_get_thumbnail_url($p['productid']);
then at the bottom pass it on to smarty
Code:

$smarty->assign("rec_thumb_url",$rec_thumb_url);

finally in recommends.tpl

Code:

tmbn_url=$rec_thumb_url[num] id="product_thumbnail"

Now the images that we are able to display in recommends thanks to Balinor can take advantage of that most recommended mod of TelaFirma.

Lionel 02-25-2006 08:15 AM

ermm, the solution is not so good. It pulls the thumbs randomly too and does not match them with title.

Balinor, help?

Audiolines 07-06-2006 04:32 PM

ok, i love this code, but it want to display my prices along with my recommended products... i cant figure out the code to display that, as prices are stored in a seperate table

ecommerce 07-29-2006 08:26 PM

I kinda got lost with this mod.

Do i need to buy a mod or add on?

Whats the code and where do i put it?

I just want below the tabbed aread,

3 columns to list 3 products.

for each product i want to show
1. thumb pic
2. title of item
3. price

1 and 2 are cliackable so they go to the product page.\
im using 4.0.18

TL408 09-20-2006 01:22 PM

Re: Pictures in recommends.tpl for 3 column format
 
Just wanted to thank Balinor for the codes below. It works great as of version 4.1.3 :) YEAH!!!!!!

Just a quick question, how do I insert a simple line space so that the product title would drop down and be center under the product thumbnail? Here is how it currently looks.

http://www.mvpautoparts.com/shop/product.php?productid=17036&cat=0&page=1

Thanks again for all of your help.
-Tuan



Quote:

Originally Posted by balinor
Just a little update on this thread. Here's the code for 4.x that breaks the display up into rows of 3, allowing as many recommended products as you want (as set in General Settings/Modules Options). Just change the thumbnail width as you would like (in pixels). You can also adjust the number of columns by changing the width of the td and the 'div by x' where x is the number of columns:

Code:

{if $recommends}
{capture name=recommends}
{section name=num loop=$recommends}
{ if %num.first% }
<table border=0 width=100%>{/if}
{ if %num.index% is div by 3}<tr>{/if}

<td width="33%" align="center" valign="top">
<a href=product.php?productid={$recommends[num].productid}&cat={$cat}&page={$navigation_page}>{include file="product_thumbnail.tpl" productid=$recommends[num].productid image_x=100 product=$recommends[num].product tmbn_url=$recommends[num].tmbn_url}

<SPAN class="ItemsList">{$recommends[num].product}</SPAN>

</td>

{ if %num.last% }</tr>
</table>{/if}
{/section}
{/capture}
{include file="dialog.tpl" title=$lng.lbl_recommends content=$smarty.capture.recommends extra="width=100%"}
{/if}



TL408 09-23-2006 06:25 PM

Re: Pictures in recommends.tpl for 3 column format
 
Hi ETInteractive,

Would you be so kind and help the us, the code-challenged people, in getting this done? I've tried to looked in the two files you mentioned below, but didn't quite understand what needs to be replaced.

This is the same issue I have with the "Best Sellers" module as well. It is calling all the thumbnails via the "image.php" file. Very, very slow. http://forum.x-cart.com/showthread.php?t=25194

My guess is that we have to replace this code
Code:

<a href=product.php?productid={$recommends[num].productid}&cat={$cat}&page={$navigation_page}>{include file="product_thumbnail.tpl" productid=$recommends[num].productid image_x=80 product=$recommends[num].product tmbn_url=$recommends[num].tmbn_url}

With something similar like this one (from the Manufacturer template). But I haven't be able to figure the exact syntax format yet. :(
Code:

<A href="manufacturers.php?manufacturerid={$manufacturers[mid].manufacturerid}">
<img src=images/M/{$manufacturers_menu[mid].manufacturer|replace:' ':''}.jpg /></a>



Quote:

Originally Posted by ETInteractive.com
Just look at products.tpl or products_t.tpl

this has the smarty call for product thumbnails.


ranger82nd 09-25-2006 10:45 AM

Re: Pictures in recommends.tpl for 3 column format
 
Does anyone know how to pull the images from the filesystem rather then from image.php?
This causes the product pages to load much slower!

kunal 09-26-2006 12:19 PM

Re: Pictures in recommends.tpl for 3 column format
 
hi

For some reason i can't find where to set the max number of products to show in the Recommended list ?

ranger82nd 09-26-2006 12:23 PM

Re: Pictures in recommends.tpl for 3 column format
 
General Settings>Module Options>Number of products to be displayed in recommended products list:

kunal 09-26-2006 12:33 PM

Re: Pictures in recommends.tpl for 3 column format
 
Thanks for that.

I was having a blank moment.

TL408 09-28-2006 05:30 AM

Re: Pictures in recommends.tpl for 3 column format
 
Well, just to update everyone on this thread, I contacted the X-cart team and Eugene Kaznacheev in the technical support team was able to ressolve the issue. Of course that cost me some support point, but I thought it was well worth it. All of my images from the "Best Sellers" and "Recommended Products" are now being referenced via the direct filesystem path and no longer being pulled via "image.php" file. WOW, they are so much faster. Night and day difference!!!

With that being said, I'm posting the code modification required to make this work down below. Hopefully this will help someone in the future.

Cheers
-Tuan



1. Edit <xcart_dir>/modules/Bestsellers/bestsellers.php script and replace:

Code:

$smarty->assign("bestsellers",$bestsellers);

with

Code:

foreach ($bestsellers as $i=>$item) {
$bestsellers[$i]["tmbn_url"] = func_get_image_url($item[productid],"T");
}

$smarty->assign("bestsellers",$bestsellers);


2. Then edit <xcart_dir>/recommends.php file and replace:

Code:

$smarty->assign("recommends",$recommends);

with

Code:

foreach ($recommends as $i=>$item) {
$recommends[$i]["tmbn_url"] = func_get_image_url($item[productid],"T");
}

$smarty->assign("recommends",$recommends);


---------------------------------------------------------------------------------------------------------------------

After that, you would need to modify the "xcart_dir\skin1\modules\Bestsellers\bestsellers.t pl" and "xcart_dir\skin1\modules\Recommended_Products\reco mmends.tpl" files as well. And below is how I currently have those two files configure.

Cheers
-Tuan


"xcart_dir\skin1\modules\Bestsellers\bestsellers.t pl" File
Code:

{* $Id: bestsellers.tpl,v 1.8 2005/11/21 12:42:00 max Exp $ *}
{if $bestsellers}
{capture name=bestsellers}
<table cellpadding="0" cellspacing="3">
{foreach from=$bestsellers item=bestseller}
<tr>


{if $config.Bestsellers.bestsellers_thumbnails eq "Y"}
<td width="30">
<a href="product.php?productid={$bestseller.productid}&cat={$cat}&bestseller">{include file="product_thumbnail.tpl" productid=$bestseller.productid image_x=50 product=$bestseller.product tmbn_url=$bestseller.tmbn_url}</a>
</td>
{/if}

<td>
<font class="ProductPriceBestSellers">
<b><a href="product.php?productid={$bestseller.productid}&amp;cat={$cat}&amp;bestseller">{$bestseller.product}</a></b><br />
{$lng.lbl_our_price}: {include file="currency.tpl" value=$bestseller.price}<br />
</font>


</td>
</tr>
{/foreach}
</table>
{/capture}
{ include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title=$lng.lbl_bestsellers menu_content=$smarty.capture.bestsellers }
{/if}

"xcart_dir\skin1\modules\Recommended_Products\reco mmends.tpl" File
Code:

{if $recommends}
{capture name=recommends}
{section name=num loop=$recommends}
{ if %num.first% }

<table border=0 width=100%>{/if}
{ if %num.index% is div by 3}<tr>{/if}

<td width="33%" align="center" valign="top">
<a href=product.php?productid={$recommends[num].productid}&cat={$cat}&page={$navigation_page}>
{include file="product_thumbnail.tpl" productid=$recommends[num].productid image_x=80 product=$recommends[num].product tmbn_url=$recommends[num].tmbn_url}




<br />
<SPAN class="ItemsList">{$recommends[num].product}</SPAN>

</td>

{ if %num.last% }</tr>
</table>{/if}
{/section}
{/capture}
{include file="dialog.tpl" title=$lng.lbl_recommends content=$smarty.capture.recommends extra="width=100%"}
{/if}




Quote:

Originally Posted by TL408
Hi ETInteractive,

Would you be so kind and help the us, the code-challenged people, in getting this done? I've tried to looked in the two files you mentioned below, but didn't quite understand what needs to be replaced.

This is the same issue I have with the "Best Sellers" module as well. It is calling all the thumbnails via the "image.php" file. Very, very slow. http://forum.x-cart.com/showthread.php?t=25194

My guess is that we have to replace this code
Code:

<a href=product.php?productid={$recommends[num].productid}&cat={$cat}&page={$navigation_page}>{include file="product_thumbnail.tpl" productid=$recommends[num].productid image_x=80 product=$recommends[num].product tmbn_url=$recommends[num].tmbn_url}

With something similar like this one (from the Manufacturer template). But I haven't be able to figure the exact syntax format yet. :(
Code:

<A href="manufacturers.php?manufacturerid={$manufacturers[mid].manufacturerid}">
<img src=images/M/{$manufacturers_menu[mid].manufacturer|replace:' ':''}.jpg /></a>



ranger82nd 09-29-2006 06:22 AM

Re: Pictures in recommends.tpl for 3 column format
 
For those of you using DSEFU and Telefirma's image mod's:
THIS IS ONLY FOR RCOMMENDED PRODUCTS AND I"M USING 2 COLUMNS

recommends.php find:
Code:

$smarty->assign("recommends",$recommends);
Replace with:
Code:

foreach ($recommends as $i=>$item) {
$recommends[$i]["tmbn_url"] = func_get_thumbnail_url($item[productid]);
}

$smarty->assign("recommends",$recommends);


recommends.tpl should look like:
Code:

{if $recommends}
{capture name=recommends}
{section name=num loop=$recommends}
{ if %num.first% }
<table border=0 width=100%>{/if}
{ if %num.index% is div by 2}<tr>{/if}

<td width="50%" align="center" valign="center">

<a href="{seo_link prod_name=$recommends[num].product prod_id=$recommends[num].productid}">{include file="product_thumbnail.tpl" productid=$recommends[num].productid image_x=$config.Appearance.product_image_width product=$recommends[num].product tmbn_url=$recommends[num].tmbn_url alt=$recommends[num].product|escape}</a><br />

<SPAN><b><A href="{seo_link prod_name=$recommends[num].product prod_id=$recommends[num].productid}">{$recommends[num].product}</A></b></SPAN>

</td>

{ if %num.last% }</tr>
</table>{/if}
{/section}
{/capture}
{include file="dialog.tpl" title=$lng.lbl_recommends content=$smarty.capture.recommends extra="width=100%"}
{/if}

If you want 3 columns change { if %num.index% is div by 2} to a 3 and <td width="50%" align="center" valign="center"> to 33%

lootsale 10-09-2006 05:58 PM

Re: Pictures in recommends.tpl for 3 column format
 
hi guys, hw would you show price on recommeds.tpl. check this out http://www.lootsale.co.uk/product.php?productid=37901&cat=328&page=1

i have managed to show prices under upselling products but recommended products price seems to be pain. Plz help?

ive tired £{$recommends[num].price} and £{$recommends[num].taxed_price} but none of them works...

daveb1 10-21-2006 10:52 AM

Re: Pictures in recommends.tpl for 3 column format
 
Great mod. Balinor's version (post #22) works perfectly in 4.0.15. I added a <br> before
Code:

<SPAN class="ItemsList">{$recommends[num].product}</SPAN>
so it put the link under the image, other than that it was perfect!


All times are GMT -8. The time now is 12:33 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.