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

echo ausgeben

 
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
halloweb
Smarty Regular


Joined: 23 Nov 2004
Posts: 35

PostPosted: Tue Nov 30, 2004 9:39 pm    Post subject: echo ausgeben Reply with quote

Ich m?chte "Vorname fehlt" mit
Code:
{$Vorname_fehlt}
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
View user's profile Send private message
halloweb
Smarty Regular


Joined: 23 Nov 2004
Posts: 35

PostPosted: Tue Nov 30, 2004 11:20 pm    Post subject: Reply with quote

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


Joined: 22 Aug 2004
Posts: 69
Location: AT

PostPosted: Wed Dec 01, 2004 8:40 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
halloweb
Smarty Regular


Joined: 23 Nov 2004
Posts: 35

PostPosted: Thu Dec 02, 2004 10:45 am    Post subject: Reply with quote

Hallo Thomas,

mit dem Code:

Code:
if(empty($Vorname))
{
$Vorname_fehlt = &quot;Fehlt&quot;;
}
smarty-&gt;assign(&quot;Vorname_fehlt&quot;,$Vorname_fehlt);
smarty-&gt;display(&quot;vorname-fehlt.tpl&quot;);


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


Question

________
volcano digital vaporizer

Last edited by halloweb on Wed Feb 02, 2011 7:07 pm; edited 2 times in total
Back to top
View user's profile Send private message
T.
Smarty Regular


Joined: 22 Aug 2004
Posts: 69
Location: AT

PostPosted: Thu Dec 02, 2004 10:48 am    Post subject: Reply with quote

du solltest auch nicht einfach den code kopieren sondern auch mal schaun, wo ich mich vertippt hab Wink Wink

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 Wink

mfg
_________________
Oppossom - Heavy rock from austria
Back to top
View user's profile Send private message Visit poster's website
halloweb
Smarty Regular


Joined: 23 Nov 2004
Posts: 35

PostPosted: Thu Dec 02, 2004 10:58 am    Post subject: Reply with quote

Danke Thomas,

der Code wird an der richtigen Stelle gezeigt !

Aber jetzt bekomme ich zweimal das .tpl gezeigt ?

Code:
$smarty-&gt;display(&quot;vorname-fehlt.tpl&quot;);


und unten

Code:
$smarty-&gt;display('attachment.tpl');


Wie kann ich es hinbekommen dass das vorname-fehlt.tpl nur gezeigt wird wenn auch der Vorname fehlt ?

________
Plymouth Belmont

Last edited by halloweb on Wed Feb 02, 2011 7:07 pm; edited 2 times in total
Back to top
View user's profile Send private message
T.
Smarty Regular


Joined: 22 Aug 2004
Posts: 69
Location: AT

PostPosted: Thu Dec 02, 2004 1:28 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
halloweb
Smarty Regular


Joined: 23 Nov 2004
Posts: 35

PostPosted: Thu Dec 02, 2004 1:34 pm    Post subject: Reply with quote

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


Joined: 22 Aug 2004
Posts: 69
Location: AT

PostPosted: Thu Dec 02, 2004 2:28 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Monarch
Smarty n00b


Joined: 17 Dec 2004
Posts: 3

PostPosted: Fri Dec 17, 2004 11:45 am    Post subject: empty(); Reply with quote

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
View user's profile Send private message
crashmakerMX
Guest





PostPosted: Sat Dec 18, 2004 12:51 pm    Post subject: Reply with quote

ähem.. wie wärs wenn du dafür einfach SmartyValidate benutzt? Wink
Back to top
Schaelle
Smarty Rookie


Joined: 28 Jun 2004
Posts: 12
Location: Germany, Leipzig

PostPosted: Sat Dec 18, 2004 10:30 pm    Post subject: Reply with quote

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
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