Home > Archive > PHP Smarty Templates > February 2005 > calling {$foo->bar()->bar2()} ?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
calling {$foo->bar()->bar2()} ?
|
|
| Michal Frackowiak 2005-02-10, 4:00 pm |
| 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
| |
| Michal Frackowiak 2005-02-10, 4:00 pm |
| 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
|
|
|
|
|