Monday, 8 October 2018

Mandrill API - Handlebar each loop in Table

I use the Mandrill API to send my transactional Mails via PHP.

Now I'm running in the problem, that when I try to loop through multiple vars only the last one is shown.

this is my variable for global_merge_vars

array(
        array(
            'name' => 'products',
            'content' => array(
                array(
                    "name" => "Product 1",
                    "price" => "65€"
                ),
                array(
                    "name" => "Product 2",
                    "price" => "65€"
                ),
                array(
                    "name" => "Product 3",
                    "price" => "65€"
                )
            )               
        )
    );

My issue is glued to the products part with the array as content.

So if i try the following:


 - <br>


I get

Product 1 - 65€
Product 2 - 65€
Product 3 - 65€

So far so good...

but if I try to wrap the whole thing in a table, I always just get the last array element shown...

<table>

<tr>
<td> - </td>
</tr>

</table>

results in:

Product 3 - 65€

Actually, I think, it's just a stupid mistake on my side, but right now, I have no idea what is the problem!

So thank you all in advance for your help :)



from Mandrill API - Handlebar each loop in Table

No comments:

Post a Comment