That if-statement doesn’t really make sense, you will always get a collection, even if it is empty.
You can however check if the collection is not empty, which usually makes sense if you use a list or whatever to make sure you don’t render any empty tags:
$tipptext = $page->children()->listed()->filterBy('template', 'tipp-text'); // or the solution I suggested above with both templates
if ($tipptext->isNotEmpty()) :
foreach ($tipptext as $subpage):
echo $subpage->title();
endforeach;
endif;
The only problem I have now is, that I want to create two different layouts for each template - so I tried this without success:
if ($items == $page->children()->listed()->filterBy('intendedTemplate', 'tipp')) :
foreach ($items as $subpage):
echo $subpage->title();
endforeach;
else:
if ($items == $page->children()->listed()->filterBy('intendedTemplate', 'tipp-text')) :
foreach ($items as $subpage):
echo $subpage->title();
endforeach;
endif;
Short explanation: I have a page with two different subpage templates (tipp & tipp-text). If the users choose “tipp”, the output should include an image. “tipp-text” is text only.