Reuse snippets in one-pager

I want to enable my client to create new subpages within the site. As I am using snippets and not templates, like suggested in the cookbook, it does not seem to work like I thought it would.

There are several threads about the topic already, suggesting to use intendedTemplate but the solution didn’t work for me / I didn’t understand it.


Lets say this is my content folder (I have no sub-folders within the content folder)

1_adventure
	adventure.txt
2_super_adventure
	adventure.txt
3_about
	about.txt
4_general
	general.txt
5_even_more_adventures
	adventure.txt

I want 1_adventure, 2_super_adventure, 5_even_more_adventures to use the same blueprint and php-snippet.

This php code from the cookbook worked until I noticed that I could re-use the snippets…

<?php foreach($pages->listed() as $section) {
  snippet($section->uid(), ['data' => $section]);} ?> 

Using intendedTemplate like below results in a empty page

foreach(page('home')->children() as $section) {
  snippet($section->intendedTemplate()); } ?>

So how to fix this last snippet?

Thanks in Advance!

You still have to pass the variable array.

foreach(page('home')->children() as $section) {
  snippet($section->intendedTemplate(), ['data' => $section]); 
} ?>

Unfortunately it doesn’t work. The result is a empty page, respectively a empty div.

These pages are are children of the home folder? Because

this sounds a bit contradictory. Are those pages above now children of content or children of home?

Sorry, if I wasn’t clear enough. All pages are children of content.

content
	1_adventure
		adventure.txt
	2_super_adventure
		adventure.txt
	3_about
		about.txt
	4_general
		general.txt
	5_even_more_adventures
		adventure.txt
	error
		error.txt
	home
		home.txt
	site.txt

But content or site instead of home give me an error.

foreach($site->children()->listed() as $section) {
  snippet($section->intendedTemplate(), ['data' => $section]); 
} ?>

Thank you @texnixe
So simple!