View previous topic :: View next topic |
Author |
Message |
halloweb Smarty Regular
Joined: 23 Nov 2004 Posts: 35
|
Posted: Tue Nov 30, 2004 9:39 pm Post subject: echo ausgeben |
|
|
Ich m?chte "Vorname fehlt" mit im template platzieren
Code: | if(empty($Vorname)) echo "Vorname_fehlt=".$Vorname_fehlt;
else echo "OK"; |
Code: | $smarty->assign("Vorname fehlt",$Vorname_fehlt); |
Weiss wer wo der Fehler ist ?
________
Weed news
Last edited by halloweb on Sat Mar 12, 2011 7:56 am; edited 2 times in total |
|
Back to top |
|
halloweb Smarty Regular
Joined: 23 Nov 2004 Posts: 35
|
Posted: Tue Nov 30, 2004 11:20 pm Post subject: |
|
|
Code: | $Vorname_fehlt="Vorname fehlt";
$smarty->assign("Vorname_fehlt",$Vorname_fehlt);
if(empty($Vorname)) echo $Vorname_fehlt;
else echo "OK"; |
Mit diesem Code bekomme ich jetzt {$Vorname_fehlt} im .tpl gezeigt !
Im oberen Teil
Code: | Vorname_fehlt=
<body bgcolor="">
<html><head>
<TITLE></TITLE> |
bekomme ich weiterhin den Text "Vorname_fehlt" in der index.php gezeigt ?
Und auch wenn oben OK steht , bleibt das {$Vorname_fehlt} stehen ?
________
Honda NSR50
Last edited by halloweb on Wed Feb 02, 2011 7:07 pm; edited 2 times in total |
|
Back to top |
|
T. Smarty Regular
Joined: 22 Aug 2004 Posts: 69 Location: AT
|
Posted: Wed Dec 01, 2004 8:40 am Post subject: |
|
|
Ich würde das ganze anders angehen.
in php:
if(empty($Vorname))
{
$Vorname_fehlt = "Fehlt";
}
else
{
$Vorname_fehlt = "Vorname OK";
}
bzw. würd ich den else Zweig weglassen und gar nix ausgeben, wenn der Vorname vorhanden ist.
dann smarty->assign("Vorname_fehlt",$Vorname_fehlt);
smarty->display("vorname-fehlt.tpl");
und im template
...
<p>{$Vorname_fehlt}</p>
sobald in deinem code:
Code: | if(empty($Vorname)) echo "Vorname_fehlt=".$Vorname_fehlt;
else echo "OK";[quote]
irgendwo "echo" steht wird eine Ausgabe gemacht. und dann is ja klar, das irgendwas komisches bei deiner Ausgabe rauskommt.[/quote] |
_________________ Oppossom - Heavy rock from austria |
|
Back to top |
|
halloweb Smarty Regular
Joined: 23 Nov 2004 Posts: 35
|
Posted: Thu Dec 02, 2004 10:45 am Post subject: |
|
|
Hallo Thomas,
mit dem Code:
Code: | if(empty($Vorname))
{
$Vorname_fehlt = "Fehlt";
}
smarty->assign("Vorname_fehlt",$Vorname_fehlt);
smarty->display("vorname-fehlt.tpl"); |
bekomme ich folgende Fehlermeldung :
Code: | Parse error: parse error, unexpected T_OBJECT_OPERATOR in /srv/www/htdocs/xxx/html/demo/mail.php on line 10 |
________
volcano digital vaporizer
Last edited by halloweb on Wed Feb 02, 2011 7:07 pm; edited 2 times in total |
|
Back to top |
|
T. Smarty Regular
Joined: 22 Aug 2004 Posts: 69 Location: AT
|
Posted: Thu Dec 02, 2004 10:48 am Post subject: |
|
|
du solltest auch nicht einfach den code kopieren sondern auch mal schaun, wo ich mich vertippt hab
bei:
smarty->assign("Vorname_fehlt",$Vorname_fehlt);
smarty->display("vorname-fehlt.tpl");
ghört n $ vorne dran
$smarty->assign("Vorname_fehlt",$Vorname_fehlt);
$smarty->display("vorname-fehlt.tpl");
und wenn du fehler mit zeilennumer hast, gib bitte an, welche zeile was is
mfg _________________ Oppossom - Heavy rock from austria |
|
Back to top |
|
halloweb Smarty Regular
Joined: 23 Nov 2004 Posts: 35
|
|
Back to top |
|
T. Smarty Regular
Joined: 22 Aug 2004 Posts: 69 Location: AT
|
Posted: Thu Dec 02, 2004 1:28 pm Post subject: |
|
|
Ich hab ja keinen Plan, was du vorhast, aber mach doch einfach ne if-abfrage.
if(empty($Vorname))
{
$Vorname_fehlt = "Fehlt";
$smarty->assign("Vorname_fehlt",$Vorname_fehlt);
$smarty->display("vorname-fehlt.tpl");
}
else
{
$smarty->display("vorname-fehlt-nicht.tpl");
}
Ich denke du machst hier ne User-Daten-Eingabe? Wäre es nicht einfacher, wenn du das Eingabeformular wieder anzeigst und dazu schreibst, das der Vorname fehlt? Nur so als Anregung (mach ich auf meinen Seiten so).
mfg der T. _________________ Oppossom - Heavy rock from austria |
|
Back to top |
|
halloweb Smarty Regular
Joined: 23 Nov 2004 Posts: 35
|
Posted: Thu Dec 02, 2004 1:34 pm Post subject: |
|
|
Code: | wenn du das Eingabeformular wieder anzeigst und dazu schreibst, das der Vorname fehlt? Nur so als Anregung (mach ich auf meinen Seiten so). |
Es wird das Beste sein, nicht jeder hatt eine Email-Adresse etc. !
Hab es so gemacht und funktioniert auch !
Danke nochmal
________
Atlanta Assembly
Last edited by halloweb on Wed Feb 02, 2011 7:07 pm; edited 2 times in total |
|
Back to top |
|
T. Smarty Regular
Joined: 22 Aug 2004 Posts: 69 Location: AT
|
Posted: Thu Dec 02, 2004 2:28 pm Post subject: |
|
|
Ich hab das so gelöst:
Ich überprüf einfach die abgesendeten Formulardaten nach der Reihe und setzte eine $Error Variable. Diese assign ich dann an das Template und geb einfach ganz oben im Dokument
<p>{$Error}</p> aus. Wenn die Seite zum ersten mal geladen wird, steht halt nix drin, wenn ein Fehler ist steht der Error dort, wenn eh alles passt geh ich sowieso auf ne andere Seite weiter.
mfg Thomas _________________ Oppossom - Heavy rock from austria |
|
Back to top |
|
Monarch Smarty n00b
Joined: 17 Dec 2004 Posts: 3
|
Posted: Fri Dec 17, 2004 11:45 am Post subject: empty(); |
|
|
Aus Erfahrung möchte ich vor der Verwendung von empty() um Formulare zu testen warnen, weil die Funktion ebenfalls 'true' zurück gibt, wenn die Variable '0' enthält.
strcmp oder strlen sind da sinnvoller... |
|
Back to top |
|
crashmakerMX Guest
|
Posted: Sat Dec 18, 2004 12:51 pm Post subject: |
|
|
ähem.. wie wärs wenn du dafür einfach SmartyValidate benutzt? |
|
Back to top |
|
Schaelle Smarty Rookie
Joined: 28 Jun 2004 Posts: 12 Location: Germany, Leipzig
|
Posted: Sat Dec 18, 2004 10:30 pm Post subject: |
|
|
Kann mich T. nur anschließen, kann ja mal mein genaues Beispiel posten (in dem mehrere Errors möglich sind)
Code: |
<?php
$smarty = new smarty;
$smarty->template_dir = 'templates/';
$smarty->compile_dir = 'templates/compiled/';
$i = 1;
if($fu == "bar") { $error[$i] = $errortext; $i++; }
?>
|
Und das Template
Code: |
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" colspan="{$colspan}"><b>Es sind folgende Fehler aufgetreten:</b></td>
</tr>
<tr>
<td align="left">
<ul>
{foreach from=$error item=error}
<li>{$error}</li>
{/foreach}
</ul>
</td>
</tr>
</table>
|
Also, $errortext musst halt sowas wie "Du hast X vergessen" sein, ich hab z.b. ne Language.Var drin.
Achja, und wen ich mich nicht irre: Man muss nichtmal das $i verwenden, also auch nicht das $i++ usw. - bin mir aber grad nicht sicher, kann nehmlich auch sein das die Vars doppelt gesetzt werden. |
|
Back to top |
|
|