|
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 |
aladar Smarty n00b
Joined: 30 May 2003 Posts: 2
|
Posted: Fri May 30, 2003 3:42 am Post subject: Accessing smarty variable in the {php} block |
|
|
Is there an way to access smarty variable in the {php} {/php} block? I've glance through the FAQ and Smarty Doc, but couldn't find an answer. One ugly way is to use the SESSION variable, but that defeats the purpose of using smarty variable.
Thanks for the help,
Scott Seong |
|
Back to top |
|
Wom.bat Smarty Pro
Joined: 24 Apr 2003 Posts: 107 Location: Munich, Germany
|
Posted: Fri May 30, 2003 2:54 pm Post subject: |
|
|
doesn't $this work? |
|
Back to top |
|
aladar Smarty n00b
Joined: 30 May 2003 Posts: 2
|
Posted: Fri May 30, 2003 3:28 pm Post subject: |
|
|
$this works...
To be exact, I had to use $this->_tpl_vars['variable'].
Thanks much!
Scott |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri May 30, 2003 5:40 pm Post subject: |
|
|
@messju: is there a reason that a reference isn't always returned by get_template_vars? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Fri May 30, 2003 7:15 pm Post subject: |
|
|
@boots: the reason is simply that it is not possible in php. the function returns a reference, but the '='-operator performs a copy. you allways have to request a reference explicetly with the &-operator in the assignment. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri May 30, 2003 7:38 pm Post subject: |
|
|
of course, doh. Sorry!!
I think I've gotten very used to using static classes where I pass by reference the object that I want filled (or molded) with the function results. ( eg: myclass::getvars( $myvarobj, $var ); ) This avoids the usual trickery involved with PHP return types and assignment and for me, helps me separate my data and purely functional classes. In fact, I usually setup the function return values to be either True/False or an integer return code.
As always thanks for the reply and setting me straight! |
|
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
|