diff --git a/content/collections/kb/nested-collections.md b/content/collections/kb/nested-collections.md new file mode 100644 index 00000000..9d7bcd0e --- /dev/null +++ b/content/collections/kb/nested-collections.md @@ -0,0 +1,39 @@ +--- +title: Nested collection loops +id: 889f5559-31d2-431a-9710-c09c58f0db51 +kb_categories: + - Tips, Tricks, and How-Tos +--- + +Sometimes one needs to nest collection loops, for example when implementing a master-detail page. + +The Antlers parser can't handle this form: +``` +{{ collection from="blog" }} +
+ {{ collection from="stuff" }} + {{ title }} + {{ /collection }} +
+{{ /collection }} +``` + +But this works : +``` +{{ collection:blog }} ++ {{ collection from="stuff" }} + {{ title }} + {{ /collection }} +
+{{ /collection:blog }} +``` + +And so does this one: +``` +{{ collection from="blog|events" }} ++ {{ partial:stuff_blog }} {{# contains the inner loop code #}} +
+{{ /collection }} +```