How {snippetArea} exactly works?

5 years ago

medhi
Bronze Partner | 189
+
0
-

For a long time, I am struggling with dynamic snippets, because it's a kind of magic :)

Now, I need my foreach (full of dynamic snippets) placed in a template, which is included into another template. How to redraw one dynamic snippet?

I've tried to put {snippetArea} into the included template, but ajax sends nothing to redraw. If I put it outside, an error will came up: Dynamic snippet needs to be in static snippet.

So how exactly {snippetArea} works and how is it different from common {snippet}, which is recommended in documentation to wrap dynamic snippets?

Thank you.

5 years ago

medhi
Bronze Partner | 189
+
+1
-

Solved! Thanks very much to matej21.

{snippetArea} has to be in main template (not included one) e.g. @layout.latte or view.latte. In that {snippetArea} you can include a template, which contains one static snippet wrapping some dynamic snippets.

To redraw any dynamic snippet, you have to redraw both {snippetArea} and static snippet inside included template.

And of course, you still have to handle the magic with foreach described in czech documentation.