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

foreach loop product.tpl

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 06-05-2011, 04:30 PM
 
cmaddrix cmaddrix is offline
 

Newbie
  
Join Date: Sep 2010
Posts: 4
 

Default foreach loop product.tpl

I use custom product skins and I am trying to eliminate duplicate variant images from appearing on my custom product page

I need to change the following code so that var_image_exists =Y only when $v.image_url is unique. Any suggestions?

{assign var="var_img_exists" value=""}
{foreach from=$variants item=v key=vid}
{if $v.is_image ne ""}
{assign var="var_img_exists" value="Y"}
{/if}
{/foreach}
__________________
4.4
no add-on modules
Linux Server
Reply With Quote
  #2  
Old 06-07-2011, 12:24 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: foreach loop product.tpl

That code doesn't look quite right if you want to check each image. The first line should be within the foreach loop so it gets reset each time through.

It may be difficult to tell if the images are truly unique but you may be able to compare image URLs.

If you want to compare with the previous entry in the loop then store each one and compare (untested):
Code:
{assign var=oldImg value=""} {foreach from=$variants item=v key=vid} {if $v.is_image ne "" and $v.image_url ne $oldImg} ... {assign var=oldImg value=$v.image_url} {/if} {/foreach}
But if you truly want to ensure they are all unique this should be done in the php file.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > 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 06:20 AM.

   

 
X-Cart forums © 2001-2020