|
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 |
rok°! Smarty Rookie
Joined: 10 Jan 2005 Posts: 12
|
Posted: Mon Jan 10, 2005 7:32 pm Post subject: non-case-sensitive Variable |
|
|
Hallo!
Wie frage ich eine non-case-sensitive Variable ab?
if ($var eq "hallo" || $var eq "HALLO" || $var eq "hALLO")
ist doch viel zu lang.
kann mir da jemand helfen? |
|
Back to top |
|
CaptainE Smarty Rookie
Joined: 23 Dec 2004 Posts: 22
|
Posted: Tue Jan 11, 2005 10:55 am Post subject: |
|
|
hi, also z.b. du machst das so:
Code: | {if strtolower($var) == "hallo"} |
dann ist es egal wie das in var ankomt, dann wird es in kleinbuchstaben umgesetzt und jede schreibweise von hallo wird erkannt.
zu beachten inst natürlich dass das argument das verglichen wird auch komplett klein geschrieben wird. |
|
Back to top |
|
rok°! Smarty Rookie
Joined: 10 Jan 2005 Posts: 12
|
Posted: Tue Jan 11, 2005 11:06 am Post subject: |
|
|
das ist doch aber php. ich wollte keinen phpcode in den templates verwenden.
oder geht das auch mit smarty? |
|
Back to top |
|
CaptainE Smarty Rookie
Joined: 23 Dec 2004 Posts: 22
|
Posted: Tue Jan 11, 2005 11:57 am Post subject: |
|
|
also zum einen, ich weiß nicht ob smarty dafür selbst eine funktion hat, glaube es aber ehrlich gesagt nicht
zweitens. naja, es ist eine phpfunktion, das ist schon richtig, aber da die smarty templates vor der ausführung ja in php compiliert werden ist das doch absolut kein problem. Wenn es eine Smaryfunktion geben würde die genau das macht, würde sie beim compilieren durch diese erstzt werden, daher sehe ich darin absolut kein problem. und abgesehen davon bassiert smarty nunmal auf php und deshalb wirst du nicht umhin kommen hin und wieder php funktionen direkt in templates einzusetzen, was ja auch so gedacht ist. |
|
Back to top |
|
rok°! Smarty Rookie
Joined: 10 Jan 2005 Posts: 12
|
Posted: Tue Jan 11, 2005 1:00 pm Post subject: |
|
|
hm, das ein templatesystem dafür gedacht ist, auch programmcode darin auszuführen bezweifele ich. denn ich nutze templates um sie vorm strikten programmcode zu schützen. (ich versuche es zumindest).
aber das sind alles grundsatzfragen. ich dachte nur mit einer sprache in den templates auskommen zu müssen, um den nutzer nicht noch weiter zu verwirren.
trotzdem danke für deine antwort! |
|
Back to top |
|
CaptainE Smarty Rookie
Joined: 23 Dec 2004 Posts: 22
|
Posted: Tue Jan 11, 2005 1:06 pm Post subject: |
|
|
ok, als das mit der trennung ist ein argument.
ich hab mich kurz nochmal informiert und es gibt dann wohl noch die folgende lösung:
Code: | {if $var|lower == "hallo"} |
ist im prinzip genau das gleiche aber halt per smarty
wird dann warscheinlich beim compilieren des templates in eine strtolower umgewandelt *g* |
|
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
|