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)
-   -   variantid in product.tpl? (https://forum.x-cart.com/showthread.php?t=17168)

mffowler 10-09-2005 02:02 PM

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

instinctual 10-09-2005 05:24 PM

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

See if that works for ya :wink:

mffowler 10-09-2005 11:53 PM

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

shan 10-10-2005 12:58 AM

i always use this to see whats available

http://forum.x-cart.com/viewtopic.php?t=17601

mffowler 10-10-2005 04:15 PM

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}


instinctual 10-11-2005 05:30 AM

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?

mffowler 10-11-2005 02:37 PM

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

instinctual 10-11-2005 05:00 PM

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.

mffowler 10-11-2005 11:16 PM

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


All times are GMT -8. The time now is 10:13 PM.

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