Re: [SMARTY] register_function and Objects
| From: | Roman Neuhauser | Date: | Fri, 30 Aug 2002 10:12:19 +0000 |
| Subject: | Re: [SMARTY] register_function and Objects | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-5877@lists.php.net to get a copy of this message | ||
> Date: Wed, 28 Aug 2002 06:52:39 -0500 (EST)
> From: <netshade@brainrazor.com>
> To: <smarty-general@lists.php.net>
> Subject: Re: [SMARTY] register_function and Objects
>
> I tried this method, and while it would've worked it required me to step
> outside the level of abstraction that I wanted to keep ; I messed around
> with the smarty.class.php and smart_compiler.class.php files to get it to
> work the way I wanted. Figured this might be useful to anyone else doing
> something similar ( worth noting this is from 2.2.0 ):
>
> Once you've changed the code, you can use the same old:
>
> $_SMARTY->register_function("alias",Array($obj_ref,"real_function"));
>
> syntax.
>
>
>
> /*======================================================================*\
> Function: _load_plugins
> Purpose: Load requested plugins
> Location: Smarty.class.php
> \*======================================================================*/
> // ...this is from the first statement block within the foreach() loop
> // of _load_plugins
>
> if (isset($plugin)) {
> if (!$plugin[3]) {
> if(is_array($plugin[0])){
> $fname=$plugin[0][1];
> $obj=$plugin[0][0];
> } else {
> $fname=$plugin[0];
> $obj=false;
> }
> // ...before it was incorrectly assigning the variables
> // if $plugin[0] was an array
>
>
>
> /*======================================================================*\
> Function: _compile_custom_tag
> Purpose: compile custom function tag
> Location: Smarty.compiler.class.php
> \*======================================================================*/
> // ...replace the return statement at the end of the function with this
> // block of code if(is_array($this->_plugins['function'][$tag_command][0]))
>
>
> $ostring="\$obj=\$this->_plugins['function']['$tag_command'][0][0];\$obj->".$this->_plugins['function'][$tag_command][0][1]; else
> $ostring="\$this->_plugins['function']['$tag_command'][0]";
>
> return "<?php ".$ostring."(array(".implode(',',
> (array)$arg_list)."), \$this); if(\$this->_extract) {
> extract(\$this->_tpl_vars); \$this->_extract=false; } ?>";
can you please post a patch? also, your MUA mutilates the text of
the message, so if you do post it, attach it.
thanks!
--
FreeBSD 4.6-STABLE
12:11PM up 9 days, 18:03, 7 users, load averages: 0.05, 0.06, 0.02