So, I’m creating arrays of articles from different content sections of the site. Some sections have articles broken out into grandchildren, consequently there are no ‘children’ that are articles there.
I’d like to add up all the articles throughout the site onto the homepage, but also in curated sections.
Here’s the structure:
/content/section1 // has no children
And here are the collections I’d like to create an array to include all children but not children that are sections (such as #4 or #5), just the children of those sections.
I’m thinking I need to do it this so that I can reference these article arrays in snippets as well, otherwise I’d need to redefine those
$articles arrays in the snippets, too (DRY, etc.).
A. Use Controllers — may allow merging of arrays already defined in the site controller, correct? https://getkirby.com/docs/guide/templates/controllers
B. Use Collections — each Collection file would define a collection, but could it allow merging of collections? https://getkirby.com/docs/guide/templates/collections
<?php $articlesSec2 = page('articles2')->children()->listed(); $articlesSec3 = page('articles3')->children()->listed(); $articlesSec4 = page('grandsection/section4')->children()->listed(); $articlesSec5 = page('grandsection/section5')->children()->listed(); $articlesAll = new Pages(array($articlesSec2,$articlesSec3, $articlesSec4, $articlesSec5));