|
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 |
pedrotester Smarty Regular
Joined: 06 Jun 2019 Posts: 40
|
Posted: Sun May 23, 2021 12:44 pm Post subject: Accessing constants in .tpl |
|
|
https://www.smarty.net/docs/en/language.variables.smarty.tpl#language.variables.smarty.const
We can also access constants simply like this {MY_CONSTANT}
I think it wasn't the case in early smarty v3 but now it works fine. Maybe add it to the page?
PS: after reading the warning, i don't quite see why I shouldn't directly use the constant in the TPL and instead assign a variable for it, does seem very redundant and useless |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sun May 30, 2021 8:09 am Post subject: |
|
|
Many people think that direct access to constants was an oversight in design. Way too easy to have a conflict with template functions/blocks. |
|
Back to top |
|
pedrotester Smarty Regular
Joined: 06 Jun 2019 Posts: 40
|
Posted: Mon May 31, 2021 2:17 pm Post subject: |
|
|
AnrDaemon wrote: | Way too easy to have a conflict with template functions/blocks. |
Do you have an example of such a conflict, please?
Maybe I should switch back to {$smarty.const.MY_CONST_VAL} |
|
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
|