|
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 |
dioobr Smarty n00b
Joined: 16 Jan 2016 Posts: 2
|
Posted: Sat Jan 16, 2016 12:35 am Post subject: Variable with constant name [Solved] |
|
|
I migrated from version 3.1.19 to 3.1.29 and found a great little problem. My code looked like this:
Code: | $smarty->assign('tx', ['ex' => ex, 'uv' => uv]; |
ex and uv are constant.
How is the template:
Code: | <div>{$tx.ex} - {$tx.uv}</div> |
After migration, the following message/error appears:
Code: | Notice: Undefined index: tx in /www/smarty/templates_c/d97eba2f0985c71e7b13f7a661c1daebc0a5039b_0.file.home.tpl.php on line 99
|
This is a bug? This is no longer allowed? What should I do?
Thanks!
Last edited by dioobr on Sat Jan 16, 2016 1:49 am; edited 2 times in total |
|
Back to top |
|
dioobr Smarty n00b
Joined: 16 Jan 2016 Posts: 2
|
Posted: Sat Jan 16, 2016 1:48 am Post subject: |
|
|
This is probably the most stupid question, whose solution is obvious: use the constant as a variable in the template.
Quote: | <div>{ex} - {uv}</div> |
Done. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat Jan 16, 2016 8:00 am Post subject: |
|
|
That notice would only make sense, if you are using tx when it is not assigned to template. I.e. some code path is going around your assignment, but still render the same template. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Jan 27, 2016 10:21 pm Post subject: |
|
|
Since a while you can use constants directly in templates.
This could create some ambiguity when using the {$foo.bar} syntax for array access and bar but bar is also a constant. |
|
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
|