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

Accessing Smarty Variable in Javascript??

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 10-09-2009, 03:16 AM
 
lucid lucid is offline
 

Member
  
Join Date: Sep 2004
Posts: 26
 

Default Accessing Smarty Variable in Javascript??

Hi,

I'm trying to access an extra field value from within javascript. How can I do this??


Here is what I have if it helps, it's take from the customer/main/product.tpl: I'm trying to Alert( {$v.field_value} )


Code:
{foreach from=$extra_fields item=v} {if $v.service_name eq 'Audio_Playlist_Link' } {if $v.field_value ne ''} <div id="flashPlayer"> This text will be replaced by the flash music player. {$v.field_value} </div> {literal} <script type="text/javascript"> var so = new SWFObject("http://mindandzen.com/skin1/audio/audioplayer.swf", "audioplayer", "300", "100", "7", "#FFFFFF"); alert("{$v.field_value}"); so.addVariable("xmlFile", $v.field_value ); so.write("flashPlayer"); </script> {/literal} {/if} {/if}
__________________
X-Cart Gold version 4.2.2
Reply With Quote
  #2  
Old 10-09-2009, 03:40 AM
  ambal's Avatar 
ambal ambal is online now
 

X-Cart team
  
Join Date: Sep 2002
Posts: 4,126
 

Default Re: Accessing Smarty Variable in Javascript??

moved to X-Cart Customization > Storefront Design & Template Editing in v3.x, 4.0.x, 4.1.x
__________________
Sincerely yours,
Alex Mulin
VP of Business Development for X-Cart
X-Payments product manager
Reply With Quote
  #3  
Old 10-09-2009, 06:30 AM
 
geckoday geckoday is offline
 

X-Wizard
  
Join Date: Aug 2005
Posts: 1,073
 

Default Re: Accessing Smarty Variable in Javascript??

The {literal} ... {/literal} means don't do anything smarty between those tags. You have two choices. Since you don't use any { or } in your javascript you can just remove the {literal} and {/literal}. If you think you might be adding in some ifs where you'll be using { and } you can either leave out the {literal} {/literal} and use {ldelim} and {rdelim} instead { and } in your javascript. Or you can leave in the {literal} {/literal} and change
{$v.field_value} to {/literal}{$v.field_value}{literal}.
__________________
Manuka Bay Company
X-Cart Version 4.0.19 [Linux]

UGG Boots and other fine sheepskin products
http://www.snowriver.com
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 07:26 PM.

   

 
X-Cart forums © 2001-2020