Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> JavaScript
Author Message
wiz
Involved
Involved



Joined: Oct 09, 2006
Posts: 413
Location: UK

PostPosted: Mon Jun 29, 2009 3:41 pm Reply with quote

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
 
View user's profile Send private message Visit poster's website AIM Address
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Mon Jun 29, 2009 4:28 pm Reply with quote

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";
 
View user's profile Send private message Send e-mail
wiz







PostPosted: Mon Jun 29, 2009 4:38 pm Reply with quote

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
 
duck
Involved
Involved



Joined: Jul 03, 2006
Posts: 273

PostPosted: Mon Jun 29, 2009 7:58 pm Reply with quote

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.
 
View user's profile Send private message
wiz







PostPosted: Mon Jun 29, 2009 9:13 pm Reply with quote

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
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> JavaScript

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©