Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Leere Variablen an das Template übergeben

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
BjoernBorg
Smarty n00b


Joined: 15 Mar 2013
Posts: 1

PostPosted: Fri Mar 15, 2013 9:56 am    Post subject: Leere Variablen an das Template übergeben Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sat Mar 16, 2013 11:10 am    Post subject: Reply with quote

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
View user's profile Send private message
ovnn
Smarty Regular


Joined: 14 Apr 2010
Posts: 82
Location: Germany

PostPosted: Mon Mar 18, 2013 8:39 am    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Mar 18, 2013 9:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
ovnn
Smarty Regular


Joined: 14 Apr 2010
Posts: 82
Location: Germany

PostPosted: Tue Mar 19, 2013 8:15 am    Post subject: Reply with quote

Ah cool genau so was habe ich gesucht.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP