|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
cconstantine Smarty n00b
Joined: 16 Sep 2008 Posts: 3
|
Posted: Mon Oct 13, 2008 1:37 pm Post subject: How to use .conf variables in java scr |
|
|
How to use .conf variables in java script file |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Oct 13, 2008 2:25 pm Post subject: |
|
|
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 |
|
cconstantine Smarty n00b
Joined: 16 Sep 2008 Posts: 3
|
Posted: Thu Oct 23, 2008 8:34 pm Post subject: please give me an example |
|
|
please give me an example |
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Fri Oct 24, 2008 8:17 am Post subject: |
|
|
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 |
|
cconstantine Smarty n00b
Joined: 16 Sep 2008 Posts: 3
|
Posted: Fri Oct 24, 2008 11:59 am Post subject: How to using vars in .conf !!! |
|
|
<script ...>
function foo() {ldelim}
alert({#city#});
{rdelim}
</script>
This is not working when city is defined in .conf file |
|
Back to top |
|
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
Posted: Mon Feb 16, 2009 3:43 pm Post subject: Is your config file loaded? |
|
|
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 |
|
|
|
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
|