Mailinglisten-Archive |
Mahlzeit!
Ich stehe hier gerade ziemlich auf dem Schlauch was Smarty anbelangt.
Ich m=F6chte in einer {section} einer custom function ({math}) den Wert
aus einer Variable zuweisen, die in der Section gesetzt wird. Irgendwie
komme ich damit nicht weiter....
Hier mein Template:
<html><head><title>Section Test</title></title></head><body bgcolor=3Dwhite>
{section name=3Dpeople loop=3D$FirstName}
{$FirstName[people]} {$LastName[people]}
{math equation=3D"x + y" x=3D"{$FirstName[people]}" y=3D"{$LastName[peopl=
e]}"}<br>
{/section}
</body></html>
Mein PHP Code dazu:
<?php
require_once 'Smarty.class.php';
$smarty =3D new Smarty();
$x =3D array(1, 2, 3, 4, 5);
$y =3D array(9, 8, 7, 6, 5);
$smarty->assign("FirstName", $y);
$smarty->assign("LastName", $x);
$smarty->display("test.tpl");
?>
Wenn ich das nun ausf=FChre, erhalte ich im Browser diese Fehlermeldung:
Parse error: parse error, expecting `'}'' in
/home/askwar/public_html/olg/html/templates_c/test.tpl.php on line 65
Zeile 65:
<?php smarty_func_math(array('equation' =3D> "x + y",'x' =3D>
"{$FirstName[people]"), $this); if($this->_extract) {
extract($this->_tpl_vars); $this->_extract=3Dfalse; } ?>" y=3D"<?php echo
$this->_tpl_vars['LastName'][$this->_sections['people']['properties']['ind=
ex']];?>
Wenn ich im Template bei x=3D und y=3D die { und } so entferne:
{section name=3Dpeople loop=3D$FirstName}
{%people.rownum%} {$FirstName[people]} {$LastName[people]} {math
equation=3D"x + y" x=3D"$FirstName[people]" y=3D"$LastName[people]"}<br>
{/section}
erhalte ich zwar im Browser 5 Zeilen, aber auch eine Fehlermeldung:
1 9 1
Warning: Smarty error: math: parameter x is empty in
/home/askwar/public_html/olg/html/OliG-System/smarty/Smarty.class.php on
line 1090
Das "1 9 1" kommt daher, das dies die 1. Zeile ist, bei der x den Wert 9
und y den Wert 1 hat.
Wie macht man's richtig?
Danke sehr!
Alexander Skwar
--=20
How to quote: http://learn.to/quote (german) http://quote.6x.to (english)
Homepage: http://www.digitalprojects.com | http://www.iso-top.de
iso-top.de - Die g=FCnstige Art an Linux Distributionen zu kommen
Uptime: 1 day 11 hours 56 minutes
php::bar PHP Wiki - Listenarchive