Re: [SMARTY-DEV] get_registered_object() ??

From: Date: Fri, 14 Feb 2003 14:32:22 +0000
Subject: Re: [SMARTY-DEV] get_registered_object() ??
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-692@lists.php.net to get a copy of this message
You can pass objects to functions as arguments: {$foo bar=$foo->bar} <-- good You just can't pass them as object parameters: {$foo->bar($foo->bar)} <-- no good On Fri, 2003-02-14 at 02:22, M Mohr wrote: > Hello, > > since objects cannot be passed to function as arguments and i see no > easy way to add this possibility to smarty, wouldn't it be nice to > have a function in smarty to access objects by name? > > function &get_registered_object($name) { > if (isset($this->_reg_objects[$name])) > return $this->_reg_objects[$name][0]; > } > > this could be used inside plugins to obtain references to registered > objects without relying on smarties internal $_reg_objects structure. > > for example: > > {foo object=oname}...{/foo} > > and in smarty_block_foo() we can do: > > if (isset[$params['object']]) { > $o =& $smarty->&get_registered_object($params['object']); > // user $o here > } > > so the plugins can use objects by name. similar to "item" and "key" in > {foreach}. > > any opinions/comments? > > > regards > messju -- Monte Ohrt <monte@ispi.net>

« previous php.smarty.dev (#692) next »