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)
-   -   First detailed image instead of thumbnail (https://forum.x-cart.com/showthread.php?t=15579)

Light Speed 07-30-2005 11:43 PM

First detailed image instead of thumbnail
 
Ever wanted to replace the thumbnail on the product page with the first image from your detailed images and then have your detailed images section start with the second detailed image?

Well here is how to do it :)

This code is for the 4.0 branch (the version for 3.4 and 3.5 is very similar)

You need to modify two files:
customer/product.tpl
modules/detailed_product_images/product_images.tpl

You will also need to make a new file:
modules/detailed_product_images/product_images_one.tpl

In product.tpl
find this:
Code:

<TD valign="top" align="left" rowspan="2" width="100">
{include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.image_x image_y=$product.image_y product=$product.product tmbn_url=$product.tmbn_url id="product_thumbnail"}
</TD>


replace with this:
Code:

{***----ORIGINAL THUMBNAIL----
<TD valign="top" align="left" rowspan="2" width="100">
{include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.image_x image_y=$product.image_y product=$product.product tmbn_url=$product.tmbn_url id="product_thumbnail"}
</TD>
----ORIGINAL THUMBNAIL----***}

{***--FIRST DETAILED IMAGE--***}
<td valign="top" align="left" rowspan="2" width="100">
{if $active_modules.Detailed_Product_Images ne ""}



{include file="modules/Detailed_Product_Images/product_images_one.tpl" }
{/if}
</td>
{***--FIRST DETAILED IMAGE--***}



Then in product_images.tpl
find this:
Code:

<img src="{$images[image].tmbn_url}">

Replace with this:
Code:

{***----ORIGINAL CODE-------
<img src="{$images[image].tmbn_url}" alt="{$images[image].alt|escape}">
--------ORIGINAL CODE***}

{***--Startwithsecondimage---***}
{if $images[image].tmbn_url ne $images[0].tmbn_url }
<img src="{$images[image].tmbn_url}" alt="{$images[image].alt|escape}">
{/if}
{***--Startwithsecondimage---***}



Make a new file in modules/detailed_product_images called product_images_one.tpl

Put this code in it:
Code:

{* $Id: product_images_one.tpl,v 1.7.2.2 2005/07/29 10:43:25 CCS Exp $ *}
{if $images ne ""}
<div align=left>
{section name=image}
{if $images[image].avail eq "Y"}
{if $images[image].tmbn_url}
<img src="{$images[image].tmbn_url}" alt="{$images[image].alt|escape}">
{else}
<img src="{$xcart_web_dir}/product_image.php?imageid={$images[image].imageid}" alt="{$images[image].alt|escape}">
{/if}




{/if}
{/section}
</div>
{/if}


That's it :)

slade 07-31-2005 01:30 AM

hi light speed um could u give us an example of the mod or give us a link to your site that shows an example of this mod that would be great :D

balinor 07-31-2005 05:16 AM

Don't really need an example, it does just what it says :) Nice one...moving it to Custom Mods.

Light Speed 07-31-2005 08:26 AM

Quote:

Originally Posted by slade
hi light speed um could u give us an example of the mod or give us a link to your site that shows an example of this mod that would be great :D


Yeah it's pretty straight forward :)

I have boomers cart-lab tabbed mod installed also and you can see my little mod works fine with that :)

slade 08-02-2005 02:38 AM

lol
 
oh cool nice mod :) sorry for my dumbness :oops:

Light Speed 08-02-2005 09:55 AM

Thanks! :)

Dongan 08-03-2005 03:02 AM

Hey,

Really cool mod and was looking for a long time and you saved my time a lot..

cheers !!!!!

Light Speed 08-03-2005 09:19 AM

Glad to help! :)

mortickles 08-17-2005 04:22 PM

Love it!
 
Works great! Does anyone know how this could be modified so the "detailed images" box only shows up if there are more than one detailed image? I have lots of products with only one image, and I now have one detailed image on top (nice) but a big old empty dialog box at the bottom. Looks like there is something missing.

Thanks again for the great mod!

Light Speed 08-17-2005 06:40 PM

Re: Love it!
 
Quote:

Originally Posted by mortickles
Works great! Does anyone know how this could be modified so the "detailed images" box only shows up if there are more than one detailed image? I have lots of products with only one image, and I now have one detailed image on top (nice) but a big old empty dialog box at the bottom. Looks like there is something missing.

Thanks again for the great mod!


There is probably a way to set an if statement at the detail dialog insert but I am too swamped to look into it. Maybe somebody else can take a stab at it?

shan 08-18-2005 03:49 AM

wrap it with

Code:

{if $images[1].image}

detailed include code

{/if}


mortickles 08-18-2005 04:56 AM

Thanks, Shan, worked like a charm! For the information of others following this thread, I wrapped Shan's code around the following line in customer/main/product.tpl:




{include file="modules/Detailed_Product_Images/product_images.tpl" }


Now here's another question for Shan or any other expert. If I have no image at all, how do I get the "no image" graphic to appear? Right now it's blank (where the first detailed image goes, which is where the thumbnail used to be).

I really appreciate the help!

shan 08-18-2005 04:59 AM

try

Code:

{if $images eq ""}

no image code here

{/if}


mortickles 08-18-2005 05:26 AM

Hmmm, I can't seem to get this last bit (the code to show the "no image" image) to work. I've tried inserting it in a couple of places, now the "no image" image always shows up (if there already is a detailed image, now it shows up along with the "no image" one).

Am I trying it in the wrong place? I'm assuming it should somehow go in the modules/detailed_product_images called product_images_one.tpl somewhere. (Lightspeed posted this code in the opening message of this thread.)

Again, thanks for your help! I'm awed by the quick and kind responses in this forum.

shan 08-18-2005 09:35 AM

sorry, i put

$image

instead of

$images

i updated my other post

mortickles 08-18-2005 05:59 PM

Works great now. Thanks for the great mod and the great help getting it up and running!

shan 08-28-2005 04:03 AM

more like this here

http://forum.x-cart.com/viewtopic.php?p=103505

Jon 12-30-2005 02:33 PM

If in your product.tpl you want to show the thumbnail when there is not detailed images, use:

Code:

{if $active_modules.Detailed_Product_Images ne "" && $images ne ""}

{include file="modules/Detailed_Product_Images/product_images_one.tpl" }{else}{include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.image_x image_y=$product.image_y product=$product.product tmbn_url=$product.tmbn_url id="product_thumbnail"}{/if}


Jon 12-30-2005 02:43 PM

In my detailed images it still showed the first detailed image in the detailed section below, after using it as the thumbnail.

Looking at the code of product_image.tpl I assumed this was because images were in the database.

I modified the code to start the loop iteration after the first image to fix the problem.

Code:

{section name=image loop=$images start=1}

airman 01-09-2006 05:28 AM

This is a great mod, but ? is there a way to also have the first detailed image show up as the thumbnail image in the catagory section also? Basically wanting to use the detailed image as the product image. Just curious if this can be also done?

Thanks

autolab 01-10-2006 10:19 AM

Quote:

Originally Posted by airman
This is a great mod, but ? is there a way to also have the first detailed image show up as the thumbnail image in the catagory section also? Basically wanting to use the detailed image as the product image. Just curious if this can be also done?

Thanks


I am very interested in this as well. I use the code from Lightspeed and Shan, and it works well, but it would be nice to integrate this into the thumbnail view in the category display.

Audiolines 05-02-2006 04:36 PM

love the code, but looking to do this...
we want the 2nd detailed image to popup in a seperate window when detailed images are clicked. some of our detailed images will be rather wide and will throw off the format of our xcart window.

thanks

Light Speed 05-02-2006 07:05 PM

Quote:

Originally Posted by airman
This is a great mod, but ? is there a way to also have the first detailed image show up as the thumbnail image in the catagory section also? Basically wanting to use the detailed image as the product image. Just curious if this can be also done?

Thanks

Then you would have oversized images being reduced in size by the browser. The thumbnail pages would load slowly. Not a good browsing experience for your customers.

Light Speed 05-02-2006 07:06 PM

Quote:

Originally Posted by Audiolines
love the code, but looking to do this...
we want the 2nd detailed image to popup in a seperate window when detailed images are clicked. some of our detailed images will be rather wide and will throw off the format of our xcart window.

thanks


There are pop up mods here. Just do a search and then look at my code and put it in the pop up mod.

lannyg 07-06-2006 06:55 PM

Question on mod
 
Hi,

I'm trying to apply this mod:
Quote:

<TD valign="top" align="left" rowspan="2" width="100">
{include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.image_x image_y=$product.image_y product=$product.product tmbn_url=$product.tmbn_url id="product_thumbnail"}
</TD>

I find:
Code:

</TD></TR></TABLE>

{/if}
{include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.image_x image_y=$product.image_y product=$product.product tmbn_url=$product.tmbn_url id="product_thumbnail"}
</TD>


Is this the correct place to modify and is it customer/main/product.tpl?

Thank you.

Light Speed 07-06-2006 10:23 PM

Re: Question on mod
 
Quote:

Originally Posted by lannyg
Hi,

I'm trying to apply this mod:
Quote:

<TD valign="top" align="left" rowspan="2" width="100">
{include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.image_x image_y=$product.image_y product=$product.product tmbn_url=$product.tmbn_url id="product_thumbnail"}
</TD>

I find:
Code:

</TD></TR></TABLE>

{/if}
{include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.image_x image_y=$product.image_y product=$product.product tmbn_url=$product.tmbn_url id="product_thumbnail"}
</TD>


Is this the correct place to modify and is it customer/main/product.tpl?

Thank you.


In 4.0.18 the raw code in customer/main/product.tpl looks like this:
Code:

<TD valign="top" align="left" rowspan="2" width="100">
{include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.image_x image_y=$product.image_y product=$product.product tmbn_url=$product.tmbn_url id="product_thumbnail"}
</TD>


What version are you trying to work on?

lannyg 07-07-2006 06:57 AM

Mod
 
I'm using 4.0.18. Shall I post the entire code here? I can not locate the part you modified. I find the product.tpl in customer/main, is this the correct tpl?

Light Speed 07-07-2006 11:30 AM

Re: Mod
 
Quote:

Originally Posted by lannyg
I'm using 4.0.18. Shall I post the entire code here? I can not locate the part you modified. I find the product.tpl in customer/main, is this the correct tpl?


Here is the complete customer/main/product.tpl file from 4.0.18 with the part separated out that needs replacing with code I provided in the instructions on page one of this thread.

Code:

{* $Id: product.tpl,v 1.96.2.25 2005/11/17 11:40:11 max Exp $ *}
{if $active_modules.Special_Offers}
{include file="modules/Special_Offers/customer/product_offers_short_list.tpl" product=$product}
{/if}
{include file="form_validation_js.tpl"}
{if $product.product_type eq "C" && $active_modules.Product_Configurator}
{include file="modules/Product_Configurator/pconf_customer_product.tpl"}
{else}
{capture name=dialog}
<TABLE border="0" width="100%">
<FORM name="orderform" method="post" action="cart.php?mode=add" onsubmit="javascript: return FormValidation();">
<TR>


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

<TD valign="top" align="left" rowspan="2" width="100">
{include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.image_x image_y=$product.image_y product=$product.product tmbn_url=$product.tmbn_url id="product_thumbnail"}
</TD>


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


<TD valign="top">
<SPAN class=>
{if $product.fulldescr ne ""}{$product.fulldescr}{else}{$product.descr}{/if}
</SPAN>



<TABLE width="100%" cellpadding="0" cellspacing="0" border="0">
<TR><TD colspan="2"><FONT class="ProductDetailsTitle">{$lng.lbl_details}</FONT></TD></TR>
<TR><TD class="Line" height="1" colspan="2">[img]{$ImagesDir}/spacer.gif[/img]</TD></TR>
<TR><TD colspan="2"></TD></TR>
{if $config.Appearance.show_in_stock eq "Y" and $config.General.unlimited_products ne "Y" and $product.distribution eq ""}
<TR><TD width="30%">{$lng.lbl_quantity}</TD><TD nowrap><SPAN id="product_avail_txt">{if $product.avail gt 0}{$product.avail}</SPAN>{else}{$lng.txt_no}{/if} {$lng.txt_items_available}</TD></TR>
{/if}
{if $product.weight ne "0.00"}<TR><TD width="30%">{$lng.lbl_weight}</TD><TD nowrap><SPAN id="product_weight">{$product.weight}</SPAN> {$config.General.weight_symbol}</TD></TR>{/if}
{if $active_modules.Extra_Fields ne ""}
{include file="modules/Extra_Fields/product.tpl"}
{/if}
{if $active_modules.Feature_Comparison ne ""}
{include file="modules/Feature_Comparison/product.tpl"}
{/if}
{if $active_modules.Subscriptions ne "" and $subscription}
{include file="modules/Subscriptions/subscription_info.tpl"}
{else}
<TR><TD class="ProductPriceConverting" valign="top">{$lng.lbl_price}:</TD>
<TD valign="top">
{if $product.taxed_price ne 0 || $variants ne ''}
<FONT class="ProductDetailsTitle"><SPAN id="product_price">{include file="currency.tpl" value=$product.taxed_price}</SPAN></FONT><FONT class="MarketPrice"> <SPAN id="product_alt_price">{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$product.taxed_price}</SPAN></FONT>
{if $product.taxes}
{include file="customer/main/taxed_price.tpl" taxes=$product.taxes}{/if}
{else}
<INPUT type="text" size="7" name="price">
{/if}
</TD>
</TR>
{/if}
</TABLE>



<TABLE border="0" width="100%" cellpadding="0" cellspacing="0">
<TR><TD colspan="2">
<FONT class="ProductDetailsTitle">{$lng.lbl_options}</FONT>
</TD></TR>
<TR><TD class="Line" height="1" colspan="2">[img]{$ImagesDir}/spacer.gif[/img]</TD></TR>
<TR><TD colspan="2"></TD></TR>
{if $active_modules.Product_Options ne ""}
{ include file="modules/Product_Options/customer_options.tpl"}
{/if}
<TR><TD height="25" width="30%">{$lng.lbl_quantity}{if $product.min_amount gt 1}
<FONT class="ProductDetailsTitle">{$lng.txt_need_min_amount} {$product.min_amount} {$lng.lbl_items}</FONT>{/if}</TD>
<TD>
{if $config.General.unlimited_products eq "N" and ($product.avail le 0 or $product.avail lt $product.min_amount) and $variants eq ''}
<SCRIPT type="text/javascript" language="JavaScript 1.2">
var min_avail = 1;
var avail = 0;
var product_avail = 0;
</SCRIPT>
{$lng.txt_out_of_stock}
{else}
{if $config.General.unlimited_products eq "Y"}
{math equation="x+1" assign="mq" x=$config.Appearance.max_select_quantity}
{else}
{math equation="x/y" x=$config.Appearance.max_select_quantity y=$product.min_amount assign="tmp"}
{if $tmp<2}
{assign var="minamount" value=$product.min_amount}
{else}
{assign var="minamount" value=1}
{/if}
{math equation="min(maxquantity+minamount, productquantity+1)" assign="mq" maxquantity=$config.Appearance.max_select_quantity minamount=$minamount productquantity=$product.avail}
{/if}
{if $product.distribution eq "" and !($active_modules.Subscriptions ne "" and $subscription)}
{if $product.min_amount le 1}
{assign var="start_quantity" value=1}
{else}
{assign var="start_quantity" value=$product.min_amount}
{/if}
<SCRIPT type="text/javascript" language="JavaScript 1.2">
var min_avail = {$start_quantity|default:1};
var avail = {$mq|default:1}-1;
var product_avail = {$product.avail|default:"0"};
</SCRIPT>
<SELECT id="product_avail" name="amount"{if $active_modules.Product_Options ne '' && $product_options ne ''} onchange="check_options();"{/if}>
{section name=quantity loop=$mq start=$start_quantity}
<OPTION value="{%quantity.index%}" {if $smarty.get.quantity eq %quantity.index%}selected{/if}>{%quantity.index%}</OPTION>
{/section}
</SELECT>
{else}
<SCRIPT type="text/javascript" language="JavaScript 1.2">
var min_avail = 1;
var avail = 1;
var product_avail = 1;
</SCRIPT>
<FONT class="ProductDetailsTitle">1</FONT><INPUT type="hidden" name="amount" value="1"> {if $product.distribution ne ""}{$lng.txt_product_downloadable}{/if}
{/if}
{/if}
</TD></TR>
<TR><TD colspan="2">
<INPUT type="hidden" name="mode" value="add">
{if $variants eq ''}
{include file="customer/main/product_prices.tpl"}
{/if}
{if $config.General.unlimited_products eq "Y" or ($product.avail gt 0 and $product.avail ge $product.min_amount)}
{if $js_enabled}


{if $smarty.get.pconf ne ""}
<INPUT type="hidden" name="slot" value="{$smarty.get.slot}">
<INPUT type="hidden" name="addproductid" value="{$product.productid}">
{include file="buttons/button.tpl" button_title=$lng.lbl_pconf_add_to_configuration style="button" href="javascript:if (FormValidation()) `$ldelim`document.orderform.productid.value='`$smarty.get.pconf`';document.orderform.action='pconf.php';document.orderform.submit()`$rdelim`"}



{/if}
{if $product.forsale ne "B"}
{include file="buttons/add_to_cart.tpl" style="button" href="javascript: if(FormValidation()) document.orderform.submit();"}

{if $login ne "" and $active_modules.Wishlist ne ""}
{include file="customer/add2wl.tpl"}
{/if}
{else}
{$lng.txt_pconf_product_is_bundled}
{/if}
{else}
{include file="submit_wo_js.tpl" value=$lng.lbl_add_to_cart}
{/if}
{/if}
{if $active_modules.Feature_Comparison ne ""}
{include file="modules/Feature_Comparison/product_buttons.tpl"}
{/if}



</TD>
</TR></TABLE>
</TD>
<TD align="right" valign="top" width="60">
{if $product.taxed_price gt 0 and $product.list_price gt 0 and $product.taxed_price lt $product.list_price}<TABLE border="0" width="60"><TR><TD width="55" height="56" class="SaveMoneyLabel" background="{$ImagesDir}/save_money.gif" align="center" valign="middle">


{math equation="100-(price/lprice)*100" price=$product.taxed_price lprice=$product.list_price format="%3.0f" assign=discount}
<SPAN id="save_percent">{ $discount }</SPAN>%
</TD></TR></TABLE>{/if}
</TD>
</TR>
<INPUT type="hidden" name="productid" value="{$product.productid}">
<INPUT type="hidden" name="cat" value="{$smarty.get.cat|escape:"html"}">
<INPUT type="hidden" name="page" value="{$smarty.get.page|escape:"html"}">
</FORM>
</TABLE>
{/capture}
{include file="dialog.tpl" title=$product.producttitle content=$smarty.capture.dialog extra="width=100%"}
{/if}



{include file="customer/main/send_to_friend.tpl" }
{if $active_modules.Detailed_Product_Images ne ""}



{include file="modules/Detailed_Product_Images/product_images.tpl" }
{/if}
{if $active_modules.Upselling_Products ne ""}



{include file="modules/Upselling_Products/related_products.tpl" }
{/if}
{if $active_modules.Recommended_Products ne ""}



{include file="modules/Recommended_Products/recommends.tpl" }
{/if}
{if $active_modules.Customer_Reviews ne ""}



{include file="modules/Customer_Reviews/vote_reviews.tpl" }
{/if}
{if $active_modules.Product_Options ne '' && $product_options ne ''}
<SCRIPT type="text/javascript" language="JavaScript 1.2">
check_options();
</SCRIPT>
{/if}


lannyg 07-07-2006 07:28 PM

Hello
 
I think I have another mod against this file is why it's not the same. I'll do some back tracking. Thank you for your help :)

Light Speed 07-07-2006 07:57 PM

Re: Hello
 
Quote:

Originally Posted by lannyg
I think I have another mod against this file is why it's not the same. I'll do some back tracking. Thank you for your help :)


No problem :D

Good luck getting what you need accomplished!

pnm 11-10-2006 03:33 AM

Re: First detailed image instead of thumbnail
 
Light Speed,

I'm trying to make the changes to my code, but can't find the area that needs changing in my Product_images.tpl as per your instructions. Below is a copy of whats in my Product_images.tpl can you please let me know where the code needs to be changed.

Your help would be greatly appreciated.

{if $images ne ""}
{capture name=dialog}
<DIV align="center">
{section name=image loop=$images}
{if $images[image].avail eq "Y"}
{if $images[image].tmbn_url}
<IMG src="{$images[image].tmbn_url}" alt="{$images[image].alt|escape}">
{else}
<IMG src="{$xcart_web_dir}/product_image.php?imageid={$images[image].imageid}" alt="{$images[image].alt|escape}">
{/if}
<BR>
<BR>
{/if}
{/section}
</DIV>
{/capture}
{if $smarty.capture.dialog ne ""}
{include file="dialog.tpl" title=$lng.lbl_detailed_images content=$smarty.capture.dialog extra="width=100%"}
{/if}
{/if}

pnm 11-12-2006 03:14 AM

Re: First detailed image instead of thumbnail
 
Thanks to Balinor prob solved and works nicely.

Great mod!

mangoboom 01-16-2007 01:54 AM

Re: First detailed image instead of thumbnail
 
Hi

Could you please tell me what code you changed on product_images.tpl?

thanks

pnm 01-16-2007 02:59 AM

Re: First detailed image instead of thumbnail
 
Have a look at this thread

http://forum.x-cart.com/showthread.php?t=26478

wendy.email 07-20-2007 03:33 AM

Re: First detailed image instead of thumbnail
 
Hi there, I want to do this with my version 4.1.8. can anyone instruct me? please.

wendy.email 07-20-2007 03:35 AM

Re: First detailed image instead of thumbnail
 
basically, i like to show product image first center on top, then description and others on the bottom... i can't seem to find mod for 4.1.8.
am i missing something

mangoboom 07-20-2007 05:39 AM

Re: First detailed image instead of thumbnail
 
Hi

please look at http://www.sugarrays.co.uk/shop/product.php?productid=886&cat=1&page=1 is this what you are trying to achieve? So you would have larger image at the top and then the description of the product, then finally rest of your detailed images?

if so then go to the link provided in the previous posts.

pegpub 11-24-2007 10:36 AM

Re: First detailed image instead of thumbnail
 
I have been using this mod with my live cart version 4.0.18 and love it. We are getting ready to migrate to 4.1.19 and the location of one file has changed and the other doesn't seem to exist.

So does anyone know how to implement this for 4.1.x branch?

Scott Merritt
www.pegasuspublishing.com/xcart/home.php
xcart 4.0.18 live
xcart 4.1.19 test

gargonzo 09-01-2008 08:33 AM

Re: First detailed image instead of thumbnail
 
hi folks--- is there a simple way to get this working on version: X-Cart version 4.1.9?

please advise asap. thanks

GreatLakesVacuum 01-21-2009 10:49 AM

Re: First detailed image instead of thumbnail
 
Quote:

Originally Posted by mangoboom
Hi

please look at http://www.sugarrays.co.uk/shop/product.php?productid=886&cat=1&page=1 is this what you are trying to achieve? So you would have larger image at the top and then the description of the product, then finally rest of your detailed images?

if so then go to the link provided in the previous posts.


Looks like you have since changed the way that works a lot, how do I do it like you did it?!


All times are GMT -8. The time now is 06:44 AM.

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