Hello everyone,
i have following structure example
- master-folder
master-template.txt
-- subfolder-alpha
template-a.txt
-- subfolder-beta
template-a.txt
-- subfolder-gamma
template-b.txt
-- subfolder-delta
template-b.txt
I got it how to get content from subpages en general, but how i can separate snippets in master-template.php so I can fetch content from first two subfolders with template a, than to fetch content from folders with template-b etc.?
Hello Nico,
thanks for answer!
Actualy I would include it as snippet.
So, are you suggesting, that when I use template() it should be something like this:
<?php foreach(page()->children()->template(template-a) as $page): ?>
...
<?php endforeach ?>
then
<?php foreach(page()->children()->template(template-b) as $page): ?>
...
<?php endforeach ?>
I am pretty sure I did it wrong because it’s not working but how to use it right?
template
is a field of the page, not a filter itself. So you have to filter using filterBy
:
<?php foreach(page()->children()->filterBy('template', 'template-a') as $page): ?>
...
<?php endforeach ?>
More documentation on filters: http://getkirby.com/docs/cheatsheet/pages/filterBy
I am seriously impressed of you both for such quick replies - it worked! If we, by any chance, meet, you can count on a free drink.
well, somehow you have to avoid doing actual boring work for uni