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

Variablen sind plötzliche alle Arrays

 
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
highlander
Smarty Rookie


Joined: 15 Oct 2004
Posts: 5

PostPosted: Fri Oct 15, 2004 4:22 pm    Post subject: Variablen sind plötzliche alle Arrays Reply with quote

Hallo,

ich hab ein etwas seltsames Verhalten von Smarty bemerkt.
Im Moment versuche ich herauszufinden wodran das liegt und wie man dass abgestellt.

Folgendes passiert:

Ich hole einen Datensatz mittels Adodb aus einer Datenbank ab und möchte den nun zum editieren anzeigen, dazu werden die einzelnen Feldinhalte Smarty.Variablen mittels assign zugewiesen.

Wird die Seite nun angezeigt, stehen nicht die Inhalte an den Stellen wo sie sein sollten, sondern da steht jedes mal nur 'Array'.

Das deutet darauf hin, das eben Arrays übergeben werden.
Laut print_r ist das aber nicht der Fall. Dort werden direkt die erwarteten Ausgaben gemacht.

Hat hier zufälligerweise noch jemand mit der Kombination Adodb/Smarty gearbeitet und diese Beoachtung ebenfalls gemacht ?

Auch für sonstige Ideen woran das liegen könnte bin ich dankbar.
Schließlich kann ich nicht ständig alles in Sections packen um an die Inhalte der vermeindlichen Arrays heranzukommen.

Ciao

highlander
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Fri Oct 15, 2004 6:22 pm    Post subject: Reply with quote

klingt für mich so, als machst du
$smarty->assign("name", "$value"); obwohl du eigentlich
$smarty->assign("name", $value) machen willst.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
highlander
Smarty Rookie


Joined: 15 Oct 2004
Posts: 5

PostPosted: Fri Oct 15, 2004 6:27 pm    Post subject: Reply with quote

ne, so einfach ists leider nicht Wink

es werden schon wirklich die Variablen übergeben.

wenn $rs das resultset ist, dass die Anfrage mittels Adodb zurückgibt, dann mach ich :

$s->assign("variable",$rs->fields[wert]);

wobei $s das Smarty-Object und wert der Name des Feldes in der DB ist.
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Fri Oct 15, 2004 6:35 pm    Post subject: Reply with quote

nimm var_dump($var) statt print_r($var) - das gibt dir dann auch aus obs ein string ist der "Array" enhält, oder ein leeres array ö. ä. .

und auch in smarty:
richtig: {assign var="foo" value=$bar}
falsch: {assign var="foo" value="$bar}
(gilt natürlich nicht nur für assign, sondern für attribute im allgemeinen)

hast du irgendwelche default_modifier definiert?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
highlander
Smarty Rookie


Joined: 15 Oct 2004
Posts: 5

PostPosted: Fri Oct 15, 2004 7:34 pm    Post subject: Reply with quote

ok, var_dump werd ich mir merken ..

der sagt aber - korrekterweise - das es sich um einen String handelt.
Wenn ich aber den wert dann ins Template stecke wird wohl ein array draus.

da ich nicht weiss wie ich einen default_modifer definiere gehe ich nicht davon aus dass ich das gemacht hab, aber ggf hab ichs aus versehen gemacht daher :

wie definiert man einen default_modifer ?
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Fri Oct 15, 2004 9:19 pm    Post subject: Reply with quote

nee, 'nen default-modiifer hast du dann nicht. siehe:
http://smarty.php.net/manual/en/variable.default.modifiers.php

aber irgendwo scheinst do arrays zu strings zu casten.
ich weiss nicht ob schon im php-layer oder erst im smarty-layer.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
highlander
Smarty Rookie


Joined: 15 Oct 2004
Posts: 5

PostPosted: Sat Oct 16, 2004 12:11 am    Post subject: Reply with quote

ehm ja .. wenn man etwas doof ist *g*

ich hab natürlich append benutzt anstatt assign ...
irgendwann nachts beim coden bin ich wohl auf den dreh gekommen das das append heißt um eine Variable in ein Template zuzuweisen.

Das erklärt die Probleme die ich hatte.

Aber danke für deinen Tip mit dem Cast zwischen String und Array. ich wär sonst wohl nicht so schnell drauf gekommen, dass es bei der Zuweisung passiert.

Asche auf mein Haupt Wink
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