Author |
Message |
wiz
Involved
![Involved Involved](modules/Forums/images/ranks/4stars.gif)
![](modules/Forums/images/avatars/c35d15694752e0da5cc74.gif)
Joined: Oct 09, 2006
Posts: 413
Location: UK
|
Posted:
Mon Jun 29, 2009 3:41 pm |
|
Hi guys.
Im working on a script for somebody that is using the Smarty engine. Now for anyone that doesnt know, Smarty variables look similar to this..
{$myvar}
In smarty, you can excape the engine, to process such things like PHP and Javascript. But my Javascript is in seperate files, to make the scripting more understandable.
The problem is, inside my .Js script, i need to add a link URL that contains a Smarty Variable, and as these use {}..you can imagine the outcome.
A sample line is below..
[code]
[0,"Edit Profile","","",-1,-1,0,"player.php?user={$member.id}","_self";[code]
Is there a way i can tell javascript to escape those 2 {} ??
Cheers in advance
WIZ |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Guardian2003
Site Admin
![](modules/Forums/images/avatars/125904890252d880f79f312.png)
Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam
|
Posted:
Mon Jun 29, 2009 4:28 pm |
|
Just as a side note, keep in mind that JS is processed client-side whilst PHP is processed server-side so you need to cater for a users browser having JS disabled.
I'm not the best person in the world to answer questions of JS but until someone more experienced pops in, have you tried re-assigning the variable?
In JS you can possibly do something like
Code:var member_id = "{$member.id}";
|
so you could then do
Code:
[0,"Edit Profile","","",-1,-1,0,"player.php?user=member_id","_self";
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
wiz
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Jun 29, 2009 4:38 pm |
|
Thanks Guardian
No mate, that doesnt work. Ive tried it earlier, the same theory but using php, and each time it parses the actual var in the url, not the content of the var.
Cheers
WIZ |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
duck
Involved
![Involved Involved](modules/Forums/images/ranks/4stars.gif)
![](modules/Forums/images/avatars/gallery/blank.gif)
Joined: Jul 03, 2006
Posts: 273
|
Posted:
Mon Jun 29, 2009 7:58 pm |
|
I think I am confused here? Why exactly do you want an escaped smarty variable in JS? I mean the purpose to the smarty variable is for the smarty engine to translate the variable to its value. JS works on the client side so it is not going to go thru the smarty engine once it is delivered so there really shouldn't be a need to send it to the client escaped? There will be no way to translate the variable from the client. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
wiz
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Jun 29, 2009 9:13 pm |
|
basically thats the link URL in the .tpl script i have, the actual core code is encrypted, so i cannot easily see the php.
Does this mean that i should just rewrite some sql queries to replicate what smarty is doing originally? Im not too familiar with smarty, so it is baffling the hell out of me.
Cheers
WIZ |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|