And… it doesn’t work. But what definitely bugs me is that I’m using this same snippet in similar fashion for another template, and it’s working fine as intended. May anyone have an idea why fetching won’t work on this example?
Do you really want to get a collection of pages (i.e. all children of the sondermeldungen page or only the contents of that particular subpage?
If you want to fetch all children of sondermeldungenI’d do it like this (to prevent going through the complete index:
<?php
if ($p = page('sondermeldungen')) {
foreach ($p->children()->listed()->filterBy('intendedTemplate', 'alert') as $item) {
echo $item->specialMessage()->kirbytext();
}
}
If all the children in that folder use the same alert template, then you can remove the filter.
If for some reason you really want to filter the complete index, then replace template with intendedTemplate in your code snippet above, but keep in mind that it should be avoided if not really necessary.
Thanks for reply! That helped me, especialy about optimization. I’m going to use this only on page ‘sondermeldungen’ like you described.
What still bugs me, why the original snippet I used for another content (only difference being different template) worked but it didn’t for the template ‘alert’.
I’m definitely going to change another snippets too not to plow through whole index.