Re: [SMARTY] Assign a reference to a variable
| From: | Monte Ohrt | Date: | Fri, 02 Aug 2002 14:08:30 +0000 |
| Subject: | Re: [SMARTY] Assign a reference to a variable | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-5551@lists.php.net to get a copy of this message | ||
This has come up before, and I like the idea of assigning by reference. It would be noticably more efficient, which is always a good thing. We do have a backward compatability issue, but that is probably a rare case.
How about this:
We change the default behavior of assign() to assign variables by reference. We add a new class variable $assign_by_ref which defaults to true. If you really want copies of the data assigned (backward compatible), you can set this flag to false. append() would also respect this flag.
Also realize if we assign by reference, Smarty would no longer loop through an assigned array and test that keys/values are not empty. They will just get assigned as-is. I don't recall why Smarty does this anyways... you probably don't want to assign empty keys/vals, but should that be Smarty's responsibility?
PHP 5.0 will do all of this implicitly, but that is a ways off.
Thoughts?
Monte
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. Is there a way to solve this problem? Assigning these variables exactly before it's displayed is not a solution. Salam hangat, Hendy Irawan - www.GaulDong.NET Kantor: (021) 5260467 [SoftVation] Kos: (021) 5261839 [kamar 3]-- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc.