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

variantid in product.tpl?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 10-09-2005, 02:02 PM
 
mffowler mffowler is offline
 

X-Adept
  
Join Date: Mar 2003
Location: Melbourne, Australia
Posts: 811
 

Default variantid in product.tpl?

I need to pull the variantid into the product.tpl and can't make it happen. Can anyone help me on this one?

You would think it is a variation of the call {$v.variantid} like in the check_options.tpl which shows up in the product.tpl. Ideas?

Thanks,

Mike
__________________
4.1.9
Reply With Quote
  #2  
Old 10-09-2005, 05:24 PM
 
instinctual instinctual is offline
 

eXpert
  
Join Date: Nov 2003
Posts: 247
 

Default

{$variants[k].variantid} works for me, but I've done some funky stuff to my product.tpl

See if that works for ya
__________________
Instinctual
8,000 feet up in the Rocky Mountains of Colorado
X-Cart Versions 3.5.x - 4.0.x

IF you xcart, THEN you prosper, ELSE you fail. ELSEIF xcart fails, THEN you fix it, all the WHILE {loop}\'ing {section}\'s to feed your $smarty mind.
Reply With Quote
  #3  
Old 10-09-2005, 11:53 PM
 
mffowler mffowler is offline
 

X-Adept
  
Join Date: Mar 2003
Location: Melbourne, Australia
Posts: 811
 

Default

instinctual,

Thanks- but no cigar. I guess the "k" is your item, but even replacing that with my "item" doesn't pull anything. There must be a way as the dropdown is loaded with variantid's but I can't see to pull the # out to use in in my image swap a href. Ideas?

Thanks for your help. Just in case, here's the code I am trying to use to include the variantid. You can see it in the <a href>:
Code:
{assign var="image_counter" value=0} {section name=swatch loop=$variants} {if $image_counter is div by 2} <tr> {assign var="image_counter" value=0} {/if} {math equation="x+1" x=$image_counter assign="image_counter" } <td width="20" valign="top"></td> {foreach item=item key=key from=$variants[swatch].options} <td width="16" height="16" valign="top" class="{$item.option_name|replace:" ":""|replace:"/":""|replace:".":""}">[img]{$ImagesDir}/resources/dot_clear.gif[/img]</td> <td valign="top"> {*** <A HREF="javascript:swapImage('image.php?productid={$product.productid}&variantid={$variants[v].variantid}');"> ***} {$item.option_name}</td> {/foreach} {capture name=image_index} {math equation="index+x+1" index=$image_counter x=2} {/capture} {if $image_counter is div by 2 } </tr> {/if} {/section}
Thanks, Mike
__________________
4.1.9
Reply With Quote
  #4  
Old 10-10-2005, 12:58 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

i always use this to see whats available

http://forum.x-cart.com/viewtopic.php?t=17601
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #5  
Old 10-10-2005, 04:15 PM
 
mffowler mffowler is offline
 

X-Adept
  
Join Date: Mar 2003
Location: Melbourne, Australia
Posts: 811
 

Default

To call the variantid, I simply needed to refer to it by name:

Code:
{$variants[swatch].variantid}

But, does anyone know what statement I can wrap around my A HREF so that if there isn't an image for the variant, it isn't a link? The color swatch uses an onclick, but how can I take advantage of the checkoptions and do this for a plain link? That is my final issue in the progression of my auto-generated swatches....

Thanks for your help,

Mike

Code:
{assign var="image_counter" value=0} {section name=swatch loop=$variants} {if $image_counter is div by 2} <tr> {assign var="image_counter" value=0} {/if} {math equation="x+1" x=$image_counter assign="image_counter" } <td width="20" valign="top"></td> {foreach item=item key=key from=$variants[swatch].options} <td width="16" height="16" valign="top" class="{$item.option_name|replace:" ":""|replace:"/":""|replace:".":""}">[img]{$ImagesDir}/resources/dot_clear.gif[/img]</td> <td valign="top"> {*** {$item.option_name} ***} {$item.option_name} </td> {/foreach} {capture name=image_index} {math equation="index+x+1" index=$image_counter x=2} {/capture} {if $image_counter is div by 2 } </tr> {/if} {/section}
__________________
4.1.9
Reply With Quote
  #6  
Old 10-11-2005, 05:30 AM
 
instinctual instinctual is offline
 

eXpert
  
Join Date: Nov 2003
Posts: 247
 

Default

I'm wondering if something like this would do the trick:


Code:
{if $image_counter ne ''} <A HREF="javascript:swapImage('image.php?productid={$product.productid}&variantid={$variants[swatch].variantid}');"> {/if} {$item.option_name} {if $image_counter ne ''} </A> {/if}

I'm assuming you're using that image counter to count the # of images in your swatch, not sure. If so, if that eq 0, you have no image?
__________________
Instinctual
8,000 feet up in the Rocky Mountains of Colorado
X-Cart Versions 3.5.x - 4.0.x

IF you xcart, THEN you prosper, ELSE you fail. ELSEIF xcart fails, THEN you fix it, all the WHILE {loop}\'ing {section}\'s to feed your $smarty mind.
Reply With Quote
  #7  
Old 10-11-2005, 02:37 PM
 
mffowler mffowler is offline
 

X-Adept
  
Join Date: Mar 2003
Location: Melbourne, Australia
Posts: 811
 

Default

Close- it gives me the "Image not Available" image. But, what I really need is there to be no link to make the swap. This is becuase we add many items where images are not available for every variant at the time of loading.

We are adding variant images daily, but would love to have the link present or not without having to make product by product if statements. So instead of changing the image to not present, it would not just not offer the link and show the default.

Thanks,

Mike
__________________
4.1.9
Reply With Quote
  #8  
Old 10-11-2005, 05:00 PM
 
instinctual instinctual is offline
 

eXpert
  
Join Date: Nov 2003
Posts: 247
 

Default

Oh I see what you're saying - use this then:

Code:
{if $image_counter ne ''} <A HREF="javascript:swapImage('image.php?productid={$product.productid}&variantid={$variants[swatch].variantid}');"> {else} [img]image.php?productid={$product.productid}&variantid={$variants[swatch].variantid}[/img] {/if} {$item.option_name} {if $image_counter ne ''} </A> {/if}
That what you're talking about? Just showing a regular image tag in there if the image_counter is 0.
__________________
Instinctual
8,000 feet up in the Rocky Mountains of Colorado
X-Cart Versions 3.5.x - 4.0.x

IF you xcart, THEN you prosper, ELSE you fail. ELSEIF xcart fails, THEN you fix it, all the WHILE {loop}\'ing {section}\'s to feed your $smarty mind.
Reply With Quote
  #9  
Old 10-11-2005, 11:16 PM
 
mffowler mffowler is offline
 

X-Adept
  
Join Date: Mar 2003
Location: Melbourne, Australia
Posts: 811
 

Default

I still an getting the no image available and a link is present. The if statement isn't needed for the image, it's needed for the link and whether to show the variant name as a link or as text.

It's a tricky call as it needs to basically say "If there is an image for that particular variant" be link otherwise, no. It works to call the swap of the image, but only when images exist. For items with no variant images, it needs to remain text.

Tough... always something. Thanks Instinctual for giving it a go.

- Mike
__________________
4.1.9
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 01:26 PM.

   

 
X-Cart forums © 2001-2020