X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Variant Image (https://forum.x-cart.com/showthread.php?t=36461)

Krista Williamson 01-01-2008 08:22 PM

Variant Image - Display All Variant Images on Product - Filter "X"
 
The code below displays all available variant images for a product and their names (on the product page - product.tpl). The problem I am having is that if the variant has no image then what is displaying is a dead/missing image. What I would like is if a variant has no image then it would be completely excluded from displaying an image and its text. In other words only variants with images will show their image and name by this code. Any suggestions would be greatly appreciated!

Quote:

{if $variants ne ""}
<table cellpadding="0" cellspacing="0" border="0">
<tr>
{foreach name=variants from=$variants item=var}
<td width="160">
<img src="{$var.image_url}" width="200" height="200">
<br />
{foreach from=$var.options item=o}
{$o.option_name}
{/foreach}
<br /><br />
</td>
{if $smarty.foreach.variants.iteration is div by 3}
</tr>
<tr>
{elseif not $smarty.foreach.variants.last}
<td></td>
{/if}
{/foreach}
</tr>
</table>
{/if}

Krista Williamson 01-03-2008 11:20 AM

Re: Variant Image
 
I know the issue is with my initial if statement
Quote:

{if $variants ne ""}

Does anyone know a good smarty variable to check against to see if the variant image contains a image or is blank.

Currently the above shows all the variant images in the product but also puts "X" images for variants that do not have their own image. I need to filter/remove the variant image display for those variants that do not have a image.

I tried various smarty variables but they seem to come across blank for the image and don't act as a proper flag.

Any suggestions would be greately appreciated.

fmoses 12-20-2008 09:06 PM

Re: Variant Image
 
Have you been able to iron out this problem?

JWait 12-25-2008 05:50 AM

Re: Variant Image
 
Have you tried adding a check to see if the is a variant image to the template? something like..
Code:

{foreach name=variants from=$variants item=var}
<td width="160">
{if $var.image_url ne ""}
<img src="{$var.image_url}" width="200" height="200">
<br />
{/if}
{foreach from=$var.options item=o}
{$o.option_name}
{/foreach}


Just a thoughy, I haven't checked it.


All times are GMT -8. The time now is 08:36 PM.

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