|
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 |
BjoernBorg Smarty n00b
Joined: 15 Mar 2013 Posts: 1
|
Posted: Fri Mar 15, 2013 9:56 am Post subject: Leere Variablen an das Template übergeben |
|
|
Hallo,
wenn man aus dem PHP Code heraus eine Variable per Code: | $smarty->assign('action', $action); | an das Template übergibt und diese Variable ein Leerstring ist, dann taucht diese Variable im Template gar nicht erst auf. Über die Debug-Console wird sie auch nicht aufgeführt.
Für die Nutzung im Template spielt das erst einmal keine Rolle. Allerdings finde ich in meinen PHP Error-Log tausende PHP Notices wie diese hier:
Code: |
PHP Notice: Undefined index: action in /templates_c/bebe87939ab0aba80012fd043177e4ba1d605f55.file.main.html.php on line 37
PHP Notice: Trying to get property of non-object in /templates_c/59aa38f01cfd3fa16651c02e2b78f5e2e2442d79.file.login.html.php on line 57
|
Nun ist es für mich sehr schwer diese eigentlich unbedeutenden Meldungen auszusortieren, um dann schneller einen Überblick über alle anderen Notices zu erhalten.
Meine Frage ist nun: Kann man Smarty irgendwie so konfigurieren, so dass auch leere Variablen im Template verfügbar sind? Also dass ALLE Variablen an das Template übergeben werden - ob sie nun einen Leerstring enthalten oder NULL / nicht definiert sind?
Danke für alle Hinweise! |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sat Mar 16, 2013 11:10 am Post subject: |
|
|
Leer Strings oder null Werte werden übergeben.
Die Fehlermeldung deutet darauf hin dass Dein $smarty->assign() gar nicht auf gerufen wurde. Dann ist die Variable im Template nicht bekannt. |
|
Back to top |
|
ovnn Smarty Regular
Joined: 14 Apr 2010 Posts: 82 Location: Germany
|
Posted: Mon Mar 18, 2013 8:39 am Post subject: |
|
|
Diese noticed Dinger kenne ich auch.
Habe das Problem aber mehr bei Arrays das hier und da ein Spalte leer ist und dann die notice kommt.
Irgendwie wäre es cool wenn man Global definieren könne das Smarty diese notices nicht wirft.
Weil überall isset(xxxxxx) zu schreiben ist irgendwie auch doof. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Mar 18, 2013 9:37 pm Post subject: |
|
|
Die E_NOTICE Meldungen können während der Ausführung von Template unterdrückt werden.
Code: | $smarty->setErrorReporting(E_ALL ^ E_NOTICE); |
|
|
Back to top |
|
ovnn Smarty Regular
Joined: 14 Apr 2010 Posts: 82 Location: Germany
|
Posted: Tue Mar 19, 2013 8:15 am Post subject: |
|
|
Ah cool genau so was habe ich gesucht. |
|
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
|