Call method inside macros

Notice: This thread is very old.
Facedown
Member | 38
+
0
-

Hi,

in Latte I want to use this code:

{if $comments->valid()}
    {foreach $comments as $comment}
        {control discussion-$comment->id()}
    {/foreach}
{else}
    <p>V diskuzi nejsou žádné komentáře</p>
{/if}

but it does not work and I end up with “Undefined property: Bulletpoint\Model\Conversation\ConstantComment::$id”. But when I use as a workaround this:

{if $comments->valid()}
    {foreach $comments as $comment}
        {var id = $comment->id()}
        {control discussion-$id}
    {/foreach}
{else}
    <p>V diskuzi nejsou žádné komentáře</p>
{/if}

It works perfectly fine.

So, it is even possible to call method inside a macro? On the Planette I have seen, examples, where is also called just $something->id instead of $somethind->id().

Thanks :)

Last edited by Facedown (2016-03-22 20:41)

Facedown
Member | 38
+
+2
-

Finally I have used

{control discussion-{$comment->id()}}