(Fwd) Re: [SMARTY] Assign a reference to a variable
| From: | Ferdinand Beyer | Date: | Fri, 02 Aug 2002 07:48:13 +0000 |
| Subject: | (Fwd) Re: [SMARTY] Assign a reference to a variable | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-5547@lists.php.net to get a copy of this message | ||
On 2 Aug 2002 at 13:39, Hendy Irawan wrote:
> smarty-general,
>
> I want to do something like:
>
> $smarty->assign('myobj', $myobj);
>
> Where $myobj is an object. However, later I want to change $myobj
> (before displaying the template) but the changes are not visible.
>
> Doing:
>
> $smarty->assign('myobj', &$myobj);
>
> seems to have no effect.
That's because Smarty::assign() does not copy references to its
$_tpl_vars variable but copies.
> Is there a way to solve this problem?
1. Modify your Smarty's assign() method to use references if a value is
passed by reference
2. This is what you don't want.... :-)
> Assigning these variables exactly before it's displayed is not a
> solution.
3. Persuade Monte to change the assign() method to be reference
save.
4. Wait for Zend Engine 2 (~ half year) that introduces a new object
model that "always uses references with objects" (Java[Script]-like
object handlers)--
Ferdinand Beyer
<fbeyer@clickhand.de>