|
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 |
bougli Smarty Rookie
Joined: 04 Oct 2018 Posts: 6
|
Posted: Mon Oct 22, 2018 7:10 am Post subject: Can i display the config label when entry is not existing ? |
|
|
Hello
I can't find anything about that.
Is there a way to display by default the translation label i used if this entry is not present in config file ?
For instance : {#something_here#}
If something_here is not present in config file, so it will display as is, instead of displaying nothing.
It's really helpful when you have several translations and texts are missing in some of them.
thanks for you help ! |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Oct 22, 2018 12:06 pm Post subject: |
|
|
`{#name#}` is not a localization string, it's a configuration variable.
In absence of value it is expanded to an empty string, which is quite predictable.
If you want proper localization, go ahead and write one.
Set up parser that will capture and account all the config variables used in your templates, and ensure they all accounted for in the respective configuration files. |
|
Back to top |
|
bougli Smarty Rookie
Joined: 04 Oct 2018 Posts: 6
|
Posted: Mon Oct 22, 2018 12:43 pm Post subject: |
|
|
Thanks for your answer, yes i'm using configuration variable.
i understand what you said, but my question is still good.
For some reasons, it would be very helpful to display the variable name when not refering to an existing entry in config files.
So the only way for me is to "hack" smarty ? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Oct 22, 2018 1:30 pm Post subject: |
|
|
No, "hacking" is what you are doing right now.
The only way out of "hacking" is to use proper tools to solve specific issues. |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Mon Oct 22, 2018 3:59 pm Post subject: |
|
|
I am not aware of any specific Smarty setting, but if you are willing to go the extra step, this may work:
Code: | {$variable|default:"<strong>{ldelim}variable{rdelim}</strong>"} | (I haven't tested this.)
See also: https://www.smarty.net/docs/en/tips.tpl#tips.blank.var.handling |
|
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
|