Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

How to use .conf variables in java scr

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
cconstantine
Smarty n00b


Joined: 16 Sep 2008
Posts: 3

PostPosted: Mon Oct 13, 2008 1:37 pm    Post subject: How to use .conf variables in java scr Reply with quote

How to use .conf variables in java script file
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Oct 13, 2008 2:25 pm    Post subject: Reply with quote

Use {ldelim} and {rdelim} to escape braces instead of putting a {literal} block around the whole thing. Then smarty tags will work in the javascript.
Back to top
View user's profile Send private message Visit poster's website
cconstantine
Smarty n00b


Joined: 16 Sep 2008
Posts: 3

PostPosted: Thu Oct 23, 2008 8:34 pm    Post subject: please give me an example Reply with quote

please give me an example
Back to top
View user's profile Send private message
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Fri Oct 24, 2008 8:17 am    Post subject: Reply with quote

Code:
<script ...>
  function foo() {ldelim}
    alert('boo');
  {rdelim}
</script>

_________________
Darn computers always do what I tell them to instead of what I want them to do.
Back to top
View user's profile Send private message
cconstantine
Smarty n00b


Joined: 16 Sep 2008
Posts: 3

PostPosted: Fri Oct 24, 2008 11:59 am    Post subject: How to using vars in .conf !!! Reply with quote

<script ...>
function foo() {ldelim}
alert({#city#});
{rdelim}
</script>

This is not working when city is defined in .conf file
Back to top
View user's profile Send private message
bimal
Smarty Elite


Joined: 19 Apr 2007
Posts: 423

PostPosted: Mon Feb 16, 2009 3:43 pm    Post subject: Is your config file loaded? Reply with quote

Have you loaded the config file?
{config_load file='config_file.conf'}

Unless you do so, the template can not access #city#.

Plus there is a serious thing to consider:
Your javascript variable (whose value is defined in #city#) is not enclosed within quotation marks (either ' or " ).

So, your correct definition should be:
alert("{#city#}");

But the major thing is that you must include your config file.
More details are at:
http://www.smarty.net/manual/en/language.config.variables.php
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP