How to check if page has children of certain template?

I am using “modules” plugin, so Kirby sees it’s content as children, but I need to check, if page has other than modules children. Use case is to show sidabar navigation, if there are children.

$modules = $page->children()->filterBy('intendedTemplate', 'in', ['list', 'of', 'module-templates'];
if ($page->children()->not($modules)) {
  // do something
}

However, it probably makes sense to have all modules in a /modules subfolder, then you only have to exclude that page.

Thank you, actually also tried if($page->hasListedChildren()) and it is working :slight_smile: Also when “modules” subpages are listed.

Will check your solution now. Yes, in this case modules are in /modules subfolder.

Looks like it’s returning the same value, if there are children or not. But it’s solved now anyway, thank you.