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

Smarty-Variablen innerhalb {php}-Tags verwenden

 
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
Owi
Smarty n00b


Joined: 01 Jul 2004
Posts: 2

PostPosted: Thu Jul 01, 2004 12:14 pm    Post subject: Smarty-Variablen innerhalb {php}-Tags verwenden Reply with quote

Hallo,
in einer älteren Smartyversion (V 2.3.1) konnte ich Smarty-[Array-]Variablen
(z.B. $sobj->assign("GLOB_ARR",array("wert1","wert2"))Wink
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
View user's profile Send private message
messju
Administrator


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

PostPosted: Thu Jul 01, 2004 12:41 pm    Post subject: Reply with quote

nicht so sauber:
$this->_tpl_vars['GLOB_ARR'][0]

sauberer:
$GLOB_ARR =& $this->get_template_vars('GLOB_ARR');
$GLOB_ARR'][0] ...
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Owi
Smarty n00b


Joined: 01 Jul 2004
Posts: 2

PostPosted: Thu Jul 01, 2004 1:08 pm    Post subject: Reply with quote

Hi!
Die saubere Lösung funktioniert. Vielen Dank!
Gruß aus Nürnberg
Oliver
Back to top
View user's profile Send private message
JOat
Smarty Rookie


Joined: 02 Sep 2004
Posts: 10

PostPosted: Sun Sep 05, 2004 4:32 am    Post subject: Reply with quote

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
View user's profile Send private message
hucky
Smarty Rookie


Joined: 02 Sep 2004
Posts: 6

PostPosted: Sun Sep 05, 2004 5:38 pm    Post subject: wiso Reply with quote

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
View user's profile Send private message
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Mon Sep 06, 2004 6:51 am    Post subject: Re: wiso Reply with quote

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