Re: [SMARTY] methods calling methods --- fatal error
| From: | Monte Ohrt | Date: | Mon, 17 Feb 2003 20:26:05 +0000 |
| Subject: | Re: [SMARTY] methods calling methods --- fatal error | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7806@lists.php.net to get a copy of this message | ||
You can't even do that in PHP.
echo $foo->bar()->foobar;
That throws a syntax error. You would have to do this first:
$tmp = $foo->bar();
$tmp->foobar;
I don't think methods from methods needs to be supported in the
templates, that's going a bit far. Can you rearrange your data?
Monte
On Mon, 2003-02-17 at 14:02, Andrew S. Nagy wrote:
> I need to call a method from a method, and it seems I can't do it directly
> (ex. $object->method()->method() ) in a template
> First I tried:
>
> {foreach from=$user->getGroup() item=group}
> In {$group->getTitle()} you are a:
> {$user->getCurrentRole($group)->getTitle()}<br/>
> {/foreach}
> this returns a syntax error
>
> then I tried:
>
> {foreach from=$user->getGroup() item=group}
> In {$group->getTitle()} you are a:
> {foreach from=$user->getCurrentRole($group)
> item=role}
> {$role->getTitle()}
> {/foreach}
> <br/>
> {/foreach}
>
> this returns a Fatal error: Call to a member function on a non-object
>
> so then i tried:
>
> {foreach from=$user->getGroup() item=group}
> In {$group->getTitle()} you are a:
> {$user->getCurrentRole p1=$group assign="role"}
> {$role->getTitle()}
> <br/>
> {/foreach}
>
> this then also returns a Fatal error: Call to a member function on a
> non-object
>
> Has anyone come across this problem? Or am I just loosing my mind?
>
> Although, I must say the new object support is making my life soooooo much
> easier! THANKS!
>
>
>
>
> ____________________________________________
> Andrew S. Nagy
> Lead Applications Developer
> Living SchoolBook
> Syracuse University
> (315) 443-3450
> http://lsb.syr.edu
--
Monte Ohrt <monte@ispi.net>