|
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 |
Owi Smarty n00b
Joined: 01 Jul 2004 Posts: 2
|
Posted: Thu Jul 01, 2004 12:14 pm Post subject: Smarty-Variablen innerhalb {php}-Tags verwenden |
|
|
Hallo,
in einer älteren Smartyversion (V 2.3.1) konnte ich Smarty-[Array-]Variablen
(z.B. $sobj->assign("GLOB_ARR",array("wert1","wert2"))
innerhalb {php}-Tags verwenden:
{php}
print $GLOB_ARR[0];
{/php}
Mit einer aktuellen Version (V 2.6.0) ist dies nicht mehr der Fall, sprich die Variable $GLOB_ARR ist leer. Wie muß ich die Variable ansprechen/übergeben, damit ich diese innerhalb von php-Tags verwenden kann?
Die Verwendung von php-Tags innerhalb von Templates ist notwendig, da ich komplexe Verarbeitungen am besten mit PHP-Funktionen erledigen kann.
Für Eure Hilfe vielen Dank im voraus
Oliver |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu Jul 01, 2004 12:41 pm Post subject: |
|
|
nicht so sauber:
$this->_tpl_vars['GLOB_ARR'][0]
sauberer:
$GLOB_ARR =& $this->get_template_vars('GLOB_ARR');
$GLOB_ARR'][0] ... |
|
Back to top |
|
Owi Smarty n00b
Joined: 01 Jul 2004 Posts: 2
|
Posted: Thu Jul 01, 2004 1:08 pm Post subject: |
|
|
Hi!
Die saubere Lösung funktioniert. Vielen Dank!
Gruß aus Nürnberg
Oliver |
|
Back to top |
|
JOat Smarty Rookie
Joined: 02 Sep 2004 Posts: 10
|
Posted: Sun Sep 05, 2004 4:32 am Post subject: |
|
|
Code: | {foreach from=$movie item=movie}
{php}{$movie.id}{/php}
{/foreach} |
das geht ja so nicht....
wie kommt ich nun im {php} {/php} and die smarty var {$movie.id}
blick da überhaupt nicht durch.... zumal das ganze ein array ist.... sonst würd ich das php zeuch scho vorher im script machen |
|
Back to top |
|
hucky Smarty Rookie
Joined: 02 Sep 2004 Posts: 6
|
Posted: Sun Sep 05, 2004 5:38 pm Post subject: wiso |
|
|
wiso willst du im php an diese variable???
ne andere frage:
$GLOB_ARR =& $this->get_template_vars('GLOB_ARR');
was bedeutet =& genau was machst du damit?
gruss |
|
Back to top |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
Posted: Mon Sep 06, 2004 6:51 am Post subject: Re: wiso |
|
|
JOat wrote: | Code: | {foreach from=$movie item=movie}
{php}{$movie.id}{/php}
{/foreach} |
das geht ja so nicht....
wie kommt ich nun im {php} {/php} and die smarty var {$movie.id}
blick da überhaupt nicht durch.... zumal das ganze ein array ist.... sonst würd ich das php zeuch scho vorher im script machen |
das geht dann so:
[php:1:ab1e3eb5d0]
$movie =& $this->get_template_vars('move');
// hier ein Objekt zugriff
echo $movie->id;
[/php:1:ab1e3eb5d0]
hucky wrote: | wiso willst du im php an diese variable???
ne andere frage:
$GLOB_ARR =& $this->get_template_vars('GLOB_ARR');
was bedeutet =& genau was machst du damit?
gruss |
"=&" initialisiert eine reference auf eine Variable
siehe:
http://de2.php.net/manual/en/language.references.php |
|
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
|