Re: [SMARTY] Re: calling {$foo->bar()->bar2()} ?
| From: | Jan Rosier | Date: | Fri, 11 Feb 2005 12:55:35 +0000 |
| Subject: | Re: [SMARTY] Re: calling {$foo->bar()->bar2()} ? | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-12237@lists.php.net to get a copy of this message | ||
Maybe this helps, not as pretty as {$foo->bar()->bar2()}, but should do the trick
{assign var="bar" value=$foo->bar()}
{$bar->bar2()}
Greetings,
Jan Rosier
* When asked how World War III would be fought, Einstein replied that he didn't know. But he knew how World War IV would be fought: With sticks and stones. *
Michal Frackowiak wrote:
Ok - now I know (thanx xo boots) - method dereferencing is not supported in PHP4 and therefore there was not much point to include it in Smarty (yet). However I think it would be a nice feature (well, I need it a LOT), so the question: "HOW TO DO THIS" remains. I would try to hack Smarty in some free time, but if there is any nice idea how to do this - it would be great! all best michal Michal Frackowiak wrote:Hi! I am starting to use Smarty in order to re-write my web portal. So far Smarty is the answer for my problems. Hovewer I was surprised that the Smarty compiler does not recognize the structure $foo->bar()->bar2() i.e. $foo->bar() returns object $foo2 and one wants to call the method bar2() on this resulting $foo2. According to the comments in the source code (Smarty_Compiler.class.php) following structures when calling objects are supported: $foo->bar $foo->bar() $foo->bar("text") $foo->bar($foo, $bar, "text") $foo->bar($foo, "foo") $foo->bar->foo() $foo->bar->foo->bar() $foo->bar($foo->bar) $foo->bar($foo->bar()) $foo->bar($foo->bar($blah,$foo,44,"foo",$foo[0].bar)) I know very little about regexp and do not feel like able to change the Smarty engine. Would the modification involve only regexps (Smarty::_obj_call_regexp and others) or compiler core as well? I think such modification would be great!!! best regards Michal